Click here to Skip to main content
14,879,536 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a user control where in there is dropdownlist. To bind dropdownlist I have passed Generic List object to a method.

public void BindDropDownList<T>(List<T> data, string val, string txt)
            foreach (var v in data)


and called this method like below.

msc_accounthead.BindDropDownList<AccountHead>(acc_list, "ahmID", "ahmHead");

for reference Click Here

How can I access properties(highlighted by green) to bind a drpdownlist?

1 solution

I don't think you ned to loop. Below should work.
ddlDropdownId.DataSource = data;
ddlDropdownId.DataTextField = txt;
ddlDropdownId.DataValueField = val;
raju@shekhar 2-May-15 9:25am
Thanks Tadit
Most welcome Raju. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900