|
-
Jul 20th, 2006, 09:34 AM
#1
Thread Starter
New Member
Populating dropdown list on formload
Hi,
I am new to .Net. plz hel me..
I am trying to populate dropdown list on page load so that later i can select one item to populate datagrid. But the drop downlist is not populating.
This is the code i used in page_load ()
if (!IsPostBack)
{
// Put user code to initialize the page here.
Connectionclass cls = new Connectionclass();
cls.ConnOpen();
DropDownList ddl = new DropDownList();
OleDbCommand cmd = new OleDbCommand("select firstname from f_userdata",cls.conn);
OleDbDataAdapter UserDA = new OleDbDataAdapter();
UserDA.SelectCommand = cmd;
DataSet UserDS = new DataSet();
UserDA.Fill(UserDS,"f_userdata");
ddl.DataSource = UserDS.Tables[0];
ddl.DataTextField = UserDS.Tables[0].Columns[0].ColumnName.ToString();
ddl.DataValueField = UserDS.Tables[0].Columns[0].ColumnName.ToString();
ddl.DataBind();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|