How to use a DropDownList in a GridView?

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?
 
G

Guest

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
 
G

Guest

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
 
S

S_K

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
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top