输出中没有错误但标签没有显示结果

时间:2014-12-09 10:26:43

标签: asp.net

 if(! ispostback){  
            ListItem book0 = new ListItem("Select Books", "-1");
            ListItem book1 = new ListItem("Electric circuits", "1");
            ListItem book2 = new ListItem("Engineering Mathematics", "2");
            ListItem book3 = new ListItem("Instrumentation engineering", "3");
            ListItem book4 = new ListItem("Programming in c#", "4");
            ListItem book5 = new ListItem("Technical English", "5");

            ddlbookavail.Items.Add(book0);
            ddlbookavail.Items.Add(book1);
            ddlbookavail.Items.Add(book2);
            ddlbookavail.Items.Add(book3);
            ddlbookavail.Items.Add(book4);
            ddlbookavail.Items.Add(book5);
        }
        else
        {
            bookavailability();   
        }
        protected void bookavailability()
   {
       lblbookavail.Visible = true;
       string s = "select BooksAvailable from tblbookinfo where Name=@bookname";
       SqlCommand cmd = new SqlCommand("select BooksAvailable from tblbookinfo where Name=@bookname", con);
       cmd.Parameters.AddWithValue("@bookname", ddlbookavail.SelectedItem.ToString());
       con.Open();
       SqlDataReader sdr = cmd.ExecuteReader();
       while (sdr.Read())
       {
           lblbookavail.Text = sdr["BooksAvailable"].ToString();/*lable is not showing result*/
       }
       con.Close();

   }

标签未在输出中显示结果。我还尝试将下半部分放在了关于下拉列表的selection_event上。但没有结果是标签。标签中显示的结果是整数。有人请帮忙。

0 个答案:

没有答案