Click here to Skip to main content
16,019,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,
suppose,I have dropdownlist box in aspx page.I was bind to table to dropdownlistbox.
that table have 5 record.like(id(1,2,3,4,5),Description(startofday,Lunchbreak,teabreak,dinnerbreak,other,endofday))
now,I want to clear my aspx page so you can understood.
in aspx page dropdown list and button.dropdown list have 5 item(startofday..etc) and button name is SignIn.
now i want display only first record like startofday in dropdown list.when i select startofday and click on signin button then after rest of record display into same dropdownlist box(lunchbreak..etc).
I dont have any code because I never implement before.
anybody can you give me this type of code or link so i can implement like this.

Thank you in advanced.
Posted

1 solution

Add dropdownlist and button to aspx page:
ASP.NET
<asp:dropdownlist id="ddlTime" runat="server">
    <asp:listitem text="startofday" value="1"></asp:listitem>
</asp:dropdownlist>

<asp:button id="btnAdd" runat="server" text="SignIn" onclick="DisplayAllItem" xmlns:asp="#unknown" />

Add following code in your code-behind file:
C#
protected void DisplayAllItem(object sender, EventArgs e)
{
    ddlTime.Items.Add(new ListItem("Lunchbreak", "2"));
	ddlTime.Items.Add(new ListItem("teabreak", "3"));
	ddlTime.Items.Add(new ListItem("dinnerbreak", "4"));
	ddlTime.Items.Add(new ListItem("other", "5"));
	ddlTime.Items.Add(new ListItem("endofday", "6"));
}
 
Share this answer
 
v2
Comments
Member 12097108 21-Jan-16 1:47am    
Hello Sir,
Thank you for this solution.
But this 5 Values store int one tabel. how can i dispaly first value like startof day after cliking signin button display rest of record.
[no name] 21-Jan-16 1:51am    
First you need to fetch data from Database. Then loop over 5 records and add it to dropdowlist(as per my answer). Go through below URL:

http://www.aspsnippets.com/Articles/Bind-Fill-Populate-DropDownList-control-from-database-in-ASPNet-using-C-and-VBNet.aspx

http://stackoverflow.com/questions/19198181/show-data-in-dropdownlist-from-sqlserver-in-asp-net-using-c-sharp

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