Add a dropDownList

S

Steph

Hello,

Could you please give me an exemple how to add a dropdownlist in a datagrid.

With this following code, I bind a datatable to a datagrid, and add a new
column. but I can't add a dropdownlist... :


DataTable dt = new DataTable();
dt = myUser.getUsers();

// Add coll
dt.Columns.Add(new DataColumn("--- Roles ---"));
//Bind
DataGrid1.DataSource = dt;
DataGrid1.DataBind();


Thanks for your help

Steph
 
A

Alvin Bruney

modify this code to use a drop list. it uses a radiobutton control.
itemdatabound event handler

if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)

{

//column 1 is an itemtemplate column

Label lbl = (Label)e.Item.FindControl("Dig");

if(lbl != null)

lbl.Text = "<input type=radio name='samegroup' value=" +
e.Item.Cells[1].Text + ">";

}
 

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,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top