How to use a DropDownList in a GridView?

  • Thread starter Thread starter S_K
  • Start date Start date
S

S_K

I have a GridView that has a DropDownList in one of the columns.
When I edit and update any row I would like to grab the SelectedValue
of that DropDownList when I'm in the GridView_RowUpdating event.

Any ideas?
 
Hi,

You can refer to the following code to get the SelectedValue of the
DropDownList in the GridView_RowUpdating event.

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
GridView1.RowUpdating
Dim s As String =
CType(GridView1.Rows(e.RowIndex).FindControl("DropDownList1"),
DropDownList).SelectedValue.ToString()
Response.Write(s)
End Sub

Hope this helps.

Regards,
Manish
 
Hi,

If you also want to know how you can use the DropDownList control in
GridView control then you can add a TemplateField in the GridView control and
then add the DropdwonList control in the ItemTemplate of that template column.

Regards,
Manish

You can also
 
Hi,

If you also want to know how you can use the DropDownList control in
GridView control then you can add a TemplateField in the GridView control and
then add the DropdwonList control in the ItemTemplate of that template column.

Regards,
Manish

You can also






- Show quoted text -

Thanks that worked!

Steve
 
Back
Top