Before Going to explain for how get dropdown selected values,we have to know how to bind the data to dropdownlist in asp.net.Here i am using SqlDataSourece control to accomplish the task.By using this we can avoid the code behind (No need to write any code) part.You can see the complete process by going through the below images
<html> <head> <title>CheckBoxList Example in Asp.net</title> </head> <body> <form id="Form1" runat="server"> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDropdown" DataTextField="CityName" DataValueField="City_Id"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDropdown" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" SelectCommand="SELECT * FROM [City]"></asp:SqlDataSource> </form> </body> </html>
1.Choose data source option from DropdownList Tasks.Then opened a wizard which will be used to select a data source and data filed for dropdowlist
2.Select the data source type and set the name of it.
3.Create a connection string to database.here i have created a test connection string which is used when we want connect to DB
4.Then select the data base table which has to be used for particular application.Then click on next and finish button on next coming wizard
5.Set the data key and data-text field for Dropdownlist using coming up wizard3.Create a connection string to database.here i have created a test connection string which is used when we want connect to DB
4.Then select the data base table which has to be used for particular application.Then click on next and finish button on next coming wizard
No comments:
Post a Comment