Creating controls at runtime
- From: pargat.singh@xxxxxxxxx
- Date: 6 Nov 2005 19:09:02 -0800
Hello Everyone:
I am new to C# and trying to create controls at runtime.
I create two listbox at run time and load the values to first one.
I disable the second listbox at time of creation[at runtime].
My requirement is when i change the first listbox value i want the
second listbox to enable and load the values .
E.g first listbox has all the countries and when i change the country i
want the second one to fille the provinces/states.
Below are the code to load the first listbox.
ListBox oObjCMB = new ListBox();
string iID = oDr.GetInt32(7).ToString().Trim();
string sSQL2 = "select * from holder where id = " + iID ;
SqlCommand oCmd3 = new SqlCommand(sSQL2,oCn2);
sqlDataReader oDr3 = oCmd3.ExecuteReader();
while(oDr3.Read())
{
oObjCMB.Items.Add(oDr3.GetValue(2).ToString().Trim());
}
TableRow tr = new TableRow();
TableCell td1 = new TableCell();
oObjCMB.ID = oDr.GetString(3);
td1.Controls.Add(oObjCMB);
Same way i create the empty listbox and disable it add to table.
Can some Please tell me how i can implement the
oObjCMB.SelectedIndexChanged
Thanks in Advance.
Pargat
.
- Follow-Ups:
- Re: Creating controls at runtime
- From: Bruce Wood
- Re: Creating controls at runtime
- Prev by Date: Re: mySQL connection problem
- Next by Date: Re: mySQL connection problem
- Previous by thread: Re: mySQL connection problem
- Next by thread: Re: Creating controls at runtime
- Index(es):
Relevant Pages
|
Loading