Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown list in a datagrid

Status
Not open for further replies.

manjulam

Programmer
Feb 27, 2002
103
US
This is what i want to do:
I have a datagrid which displays information from table1.
I have a column in the datagrid which shows a dropdown with three hard coded values as listitems say region1,region2,region3. I need to bind the value of these listitems to the id field of the selected record in the datagrid.

How do i do this?

Thanks in advance,
Manjula
 
This is what i did to make it work:

Get the value from the dropdown using dropdownlist.SelectedValue.ToString();

Get the row index from where the dropdown was clicked by looping thru
the grid and matching the sender to the dropdown control name.

for(idgLoop=0;idgLoop<=idgRowCount;idgLoop++)
{
DropDownList dList1=(DropDownList)(usersGrid.Items[idgLoop].FindControl("drpEdit"));
if(dList1==dList)
{
idgIndex=idgLoop;
break;
}

}

Get the bound column value for the selected row:

usersGrid.Items[idgIndex].Cells[0].Text;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top