dynamic obect access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have for exmaple few DDL
and i want each time to send to the function use the DDL name
and all the code in the function will be dnamic for example
ddlCountry.DataSource =...
will be
obj.DataSource =....
how can i do it?
and how can i do this by passing the function the object name
and doing the same as above?
thnaks in advance
peleg
 
i have for exmaple few DDL
and i want each time to send to the function use the DDL name
and all the code in the function will be dnamic for example
ddlCountry.DataSource =...
will be
obj.DataSource =....
how can i do it?
and how can i do this by passing the function the object name
and doing the same as above?
thnaks in advance
peleg

Hi...

check out the following code... try in your own context...

public void DoSomeJob()
{
PopulateDropdownList(ddlcountry, ObjectDataSourceCountry);
PopulateDropdownList(ddlstate, ObjectDataSourceState);
PopulateDropdownList(ddlcity, ObjectDataSourceCity);
}

public void PopulateDropdownList(DropDownList
ddl,ObjectDataSource objectdatasource)
{
ddl.DataSource = objectdatasource;
ddl.DataTextField = "Name";
ddl.DataValueField = "ID";
ddl.DataBind();
}

Thanks
Md. Masudur Rahman (Munna)
kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com
 
Back
Top