I'll work in 1 web site. And in it dropdown list is there and all items are selected in dropdown list but 3 items are not taken. Means display in dropdown but when we choose that item not display in dropdown list. What is the problem??
Thans to all....
I think this error is not coding error. It's a type of some laptop error or any other.
This is cs file.
public partial class category : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["setEmail"] == null)
Response.Redirect("login.aspx");
con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand("Select * from category1", con);
dr = cmd.ExecuteReader();
while(dr.Read())
{
dropcate.Items.Add (new ListItem(dr[1].ToString(),dr[0].ToString()));
}
con.Close();
}
This is aspx file.
<tr>
<td>
<asp:Label ID="lblcate" runat="server" Text="Category"></asp:Label>
<br />
<br />
</td>
<td>
<asp:DropDownList ID="dropcate" runat="server"
onselectedindexchanged="dropcate_SelectedIndexChanged">
</asp:DropDownList>
<br />
<br />
</td>
</tr>