Click to See Complete Forum and Search --> : alternating dropdowns


wagae
06-27-2006, 06:29 AM
Hello everyone
i have a datagrid with the second column being TypeID, on the same grid there is a dropdown, the values in the dropdown depends on the TypeID. How can i do this keeping in mind that the values on that dropdown are not on the database.

For example.
TypeID = 1
Values to show in the dd= Apple, banana, pear

TypeID = 2
Values to show in the dd = Potatoes,Tomato

How can i do this?
Thank you.

handshakeit
06-28-2006, 06:23 AM
use row created event of grid there check the value of TypeID
and set DropdownList items

handshakeit
06-28-2006, 06:28 AM
Some code try this
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string test=ds.Tables[0].Rows[e.Row.RowIndex]["TypeID"].ToString().Trim();
switch(test)
{
case 1:
{
((DropDownList)e.Row.FindControl("d")).Items.Add(new ListItem("Apple"));
((DropDownList)e.Row.FindControl("d")).Items.Add(new ListItem("banana"));
((DropDownList)e.Row.FindControl("d")).Items.Add(new ListItem("pear"));
break;
}
case 2:
{

((DropDownList)e.Row.FindControl("d")).Items.Add(new ListItem("Potatoes"));
((DropDownList)e.Row.FindControl("d")).Items.Add(new ListItem("Tomato"));
break;
}
case 3:
{
//do same
}
}
}
}