Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 19, 2007 11:11 AM by Kannandesikan
Oct 08, 2007 08:28 AM|LINK
i have one function whch is used for databinding to dropdown list.but on one page there are many dropdownlists so it crete writing same code for every dropdownlist with its name only diffrent.so i want to know how can i pass diffrent dropdownlist names to
single function using a variable which can take dropdownlist name as variable.in short i want to use same function for siffrent dropdownlists.
i am using asp.net 2.0
using varible for control names
Oct 08, 2007 08:55 AM|LINK
What is your code actually plz ?
Oct 08, 2007 09:06 AM|LINK
You can identify control using sender argument.
public function values()
Oct 08, 2007 09:15 AM|LINK
try below one...
fucntion fillDropdown(DropdownList ddl)
ddl.datasource = .......;
You can call this method as below,
fillDropdown(dropdown which you wnat to fill);
I hope this will help you.....
Oct 08, 2007 09:44 AM|LINK
Instead of Passing the name of the dropdown, pass the control to the function and in that function directly do the databinding. By this approach there is no need of passing the name of control.
(This below is sample example only for understanding puposes)
Function BindDropDown( ddState System.webcontrols.dropdownlist )
Nov 14, 2007 05:02 AM|LINK
i try this but its not working pls i wants to do to put in a comman function
bcz i have lot of dropdownlist its better for me to put as a comman function
drop down list box
Nov 14, 2007 05:17 AM|LINK
can you specify some details for your requirement?
Nov 15, 2007 06:20 AM|LINK
Hi vasanth thankx for your mail
see iam using vb.net with asp.net 2.0
If Page.IsPostBack = False Then
dt = obj.ReadTables(strsql)
drpcategory.DataSource = dt.Tables(0)
drpcategory.DataTextField = dt.Tables(0).Columns(1).ToString
drpcategory.DataValueField = dt.Tables(0).Columns(0).ToString
i wants to create comman function in class that i just want to pass dropdownlist as a parament in that function
re dropdownlist doubt
Nov 15, 2007 07:41 AM|LINK
try the below one....
public void CompanyToCopy(DropDownList dl, DataSet ds, string tabName, string textFiled, string valueFiled)
dl.DataSource = ds;
dl.DataValueField = ds.Tables[tabName].Columns[valueField].ToString();
dl.DataTextField = genericDS.Tables[tabName].Columns[textFiled].ToString();
Nov 15, 2007 09:54 AM|LINK
thank u for ur mail i need in asp.net with vb.net, i tried my own i don't no how to pass dropdownlist as parameter in function pls guid me
Public Function kannan(ByRef Drop As WebControls.DropDownList, ByRef dset As Data.DataSet, ByVal tabname As String, ByVal textfield As String, ByVal valueField As String)
Drop.DataSource = dset
Drop.DataValueField = dset.Tables(tabname).Columns(valueField).ToString()
Drop.DataTextField = dset.Tables(tabname).Columns(textfield).ToString()