Re: how to pass control in function in c#

B

Bobby Ryzhy

(Type your message here)

--------------------------------
From: nitin n

i m making one function to fill dropdownlist.
For tht i want to pass dropdownlist control to one function.

wht would be the best solution for it?

Give this a go.

private void FilDropDown(System.Web.UI.WebControls.DropDownList dropDownList)
{
try
{
DataSet packageTypes = PackageTypes.GetTypes();

foreach (DataRow row in packageTypes.Tables[0].Rows)
{
ListItem Li = new ListItem(row[1].ToString(), row[0].ToString());

dropDownList.Items.Add(Li);
}
}
catch(Exception ex)
{
friendlyError.WriteError(ex);
}
}
Bobby Ryzhy
bobby @ domain below
http://weekendtech.net
 

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

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,630
Members
45,338
Latest member
41Pearline46

Latest Threads

Top