Click here to Skip to main content
15,850,214 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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.

XML
<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>
Posted
Updated 23-Feb-13 0:53am
v5
Comments
Bhushan Shah1988 20-Feb-13 8:14am    
can't understand..!!
Abhinav S 20-Feb-13 8:19am    
How do you populate the dropdown?
Is it a query? Check if this is working correctly.
Sm.Abdullah 20-Feb-13 8:20am    
not clear ....!
Sandeep Mewara 20-Feb-13 8:43am    
Please rephrase.
ZurdoDev 20-Feb-13 10:25am    
This is not clear.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900