Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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>
Posted 20-Feb-13 3:05am
Edited 23-Feb-13 0:53am
v5
Comments
Bhushan Shah1988 at 20-Feb-13 8:14am
   
can't understand..!!
Abhinav S at 20-Feb-13 8:19am
   
How do you populate the dropdown?
Is it a query? Check if this is working correctly.
Sm.Abdullah at 20-Feb-13 8:20am
   
not clear ....!
Sandeep Mewara at 20-Feb-13 8:43am
   
Please rephrase.
ryanb31 at 20-Feb-13 10:25am
   
This is not clear.
Raja Soosai at 21-Feb-13 7:13am
   
Please post your question clearly.
bkthebest at 23-Feb-13 3:20am
   
not cleared
provide your code that you tried
Mittu Machhi at 23-Feb-13 5:25am
   
not clear
ankita 4 at 23-Feb-13 5:33am
   
I think this error is not codeing error. Any thing else. And now error is sloved. Thanx
Deenuji at 23-Feb-13 5:29am
   
post ur code????
ankita 4 at 23-Feb-13 5:36am
   
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.
 
<td>

<asp:DropDownList ID="dropcate" runat="server"
onselectedindexchanged="dropcate_SelectedIndexChanged">

<br />
<br />

</td>
 

CShubham at 23-Feb-13 5:47am
   
make your query is solved!!!!!!!!
ankita 4 at 23-Feb-13 5:49am
   
yes...

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

  Print Answers RSS
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,260


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100