how to bind drop down list form data base
Bind Drop down list form data base:
In the web development the
Drop down list is most important tool, we Use many time and many places to use
this for showing the list in hidden format.
And to fill date in to this list,
when we need on page the select a particular item in this drop down list in to asp.net Programming.
Example:
I want to fill all class names
in to drop down list which are store in the data base.
we give some steps for this ......................
step 1:
know we create a web page as name Dropdown_list_Example.aspx
take a drop down list in to page
<asp:DropDownList ID="ddlclassId"
runat="server" Width="128px"
AutoPostBack="True">
</asp:DropDownList>
here we give the drop down list id is "ddlclassId" for
understanding to drop down.
step 2:
then go to the coding page and make a function for selecting the
value form data base.
private void FillClass()
{
DataSet ds=new DataSet();
ds=objc1.Select_Class();
/*
in the
brown color coded part use for fetching data form table in to Dataset use some
class file and Store processor for this .if you have other way then put here.
we
select two values Class Name and Section Name in Class and Class Id ,Class id
is primary key ..
*/
ddlclassId.DataTextField = "Class";
//dataTextField
hold those value which are show in list .
ddlclassId.DataValueField = "ClassId";
//dataValueField
use for get unicq value of selected item.
ddlclassId.DataBind();
ddlclassId.Items.Insert(0, new ListItem("Select", "0"));
//this
line use for inserting "Select" in to list .
}
step 3:
Call this function in to page load Event .
protected void Page_Load(object
sender, EventArgs e)
{
if
(!IsPostBack)
{
FillClass();
}
}
|
Dropdownlist Related Post:
- Bind Dropdown by Dynamically
- Checkbox in asp Dropdown List.
- Fill Dropdown By database.
- Display Selected Date
- DropDown List in asp.net Programming,
- Drop Down List control of asp.net
- Add ListItem in DropDownList asp.net c# Example
- Single select option to the user from many items.
- Example of Adding ToolTip for each Dropdown List Item
- Bind Dropdown by Dynamically
- Checkbox in asp Dropdown List.
- Fill Dropdown By database.
- Display Selected Date
- DropDown List in asp.net Programming,
- Drop Down List control of asp.net
- Add ListItem in DropDownList asp.net c# Example
- Single select option to the user from many items.
- Example of Adding ToolTip for each Dropdown List Item
OtherAsp.net related post:
- Example of session in asp.net
- Session Management.
- comparevalidator in asp.net
- Post back And call back
- Required Field validator.
- What is the postback in asp.net
- Use of viewstate.
- events in asp.net
- control execution life cycle.
- Asp.net user control basics.
- server control.
- Introduction of SQL
- Create Data Table in SQL
- Cloud Service Introduction
- Image size before Uploading.
- Cloud Service Provider
- Example of session in asp.net
- Session Management.
- comparevalidator in asp.net
- Post back And call back
- Required Field validator.
- What is the postback in asp.net
- Use of viewstate.
- events in asp.net
- control execution life cycle.
- Asp.net user control basics.
- server control.
- Introduction of SQL
- Create Data Table in SQL
- Cloud Service Introduction
- Image size before Uploading.
- Cloud Service Provider
Comments
Post a Comment