dynamic obect access

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
 
M

Masudur

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top