How to use a DropDownList in a GridView?

Discussion in 'ASP .Net' started by S_K, Sep 27, 2007.

  1. S_K

    S_K Guest

    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?
     
    S_K, Sep 27, 2007
    #1
    1. Advertising

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

    "S_K" wrote:

    > 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?
    >
    >
     
    =?Utf-8?B?TWFuaXNo?=, Sep 28, 2007
    #2
    1. Advertising

  3. 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_K" wrote:

    > 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?
    >
    >
     
    =?Utf-8?B?TWFuaXNo?=, Sep 28, 2007
    #3
  4. S_K

    S_K Guest

    On Sep 28, 12:48 am, Manish <> wrote:
    > 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_K" wrote:
    > > 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?- Hide quoted text -

    >
    > - Show quoted text -


    Thanks that worked!

    Steve
     
    S_K, Sep 28, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,899
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  2. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,337
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  3. =?Utf-8?B?RGFiYmxlcg==?=
    Replies:
    6
    Views:
    13,399
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Apr 4, 2006
  4. keithb
    Replies:
    1
    Views:
    12,173
    shauns1
    Nov 1, 2006
  5. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    18,044
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
Loading...

Share This Page