Beginner gridview question

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.
 
J

jm

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.
 
P

Paul

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();
}
}
}
 

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,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top