Beginner gridview question

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Just wondering if anyone knows if this is possible with a gridview but I have
a template column with two dropdown list boxes in it and when the user makes
a selection in the first box I want to run an event that then takes the
selected value of the first dropdown and feeds it into a stored procedure
that returns a dataset that I want to display in the second dropdown list.
If there is no data returned I want to hide the second dropdown list, any
examples, thanks. I was doing this quite easily with the controls outside of
the datagrid.
Thanks.
 
Just wondering if anyone knows if this is possible with a gridview but I have
a template column with two dropdown list boxes in it and when the user makes
a selection in the first box I want to run an event that then takes the
selected value of the first dropdown and feeds it into a stored procedure
that returns a dataset that I want to display in the second dropdown list..  
If there is no data returned I want to hide the second dropdown list, any
examples, thanks.  I was doing this quite easily with the controls outside of
the datagrid.
Thanks.

If you make them template columns, you can reference them in code
easier, which may be what you did outside of the datagrid you
mentioned.
 
Thanks for the response. I think something like below may work as I am able
to access the selected values in the template column. There is also a label
in the column as well. I will just need to rebind the secondary dropdown
feeding the selected value into the datasource first.

protected void drdn1_SelectedIndexChanged(object sender, EventArgs e)
{
foreach (GridViewRow myRow in this.gvwDiscrepancies.Rows)
{
Label lbl1 = myRow.Cells[2].Controls[1] as Label;
DropDownList drdn1 = myRow.Cells[2].Controls[7] as DropDownList;
if (drdn1 != null)
{
string stemp = drdn1.SelectedValue.ToString();
}
}
}
 
Back
Top