i want 2 show dropdown on my web page with zero index fixed [select option]
as soon as user select items from a dropdown i want to do some code behind
on that index but dropdown zeroth index should remain intact
how can i achieve this?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manoj SevdaPosted Nov 21, 2011, 11:39 PM
use following code.
if(ds.Tables[0].Rows.Count>0)
{
ddlTest.Items.Clear();
ddlTest.Items.Add(new ListItem("--Select--", "0"));
foreeach(DataRow dr in ds.Tables[0].Rows)
{
ddlTest.Items.Add(new ListItem(dr["Name"].ToString(), dr["id"].ToString()));
}
}