Dropdown Inside Gridview SelectedIndexChange Event

Discussion in 'ASP .Net Web Controls' started by Babu, Dec 12, 2007.

  1. Babu

    Babu Guest

    I am having DropDownList inside GridView. When the DropDownList SelectedIndex changed a event should fire and how can I able to get the row number for the GridView
     
    Babu, Dec 12, 2007
    #1
    1. Advertising

  2. Babu

    John Padilla Guest

    Babu,

    Add a SelectedIndexChanged event, within that event you can access some of
    the GridView properties such as SelectedIndex. If this doesnt work you can do
    a cool work around like this:

    I am assuming you have Edit link button set for each gridrow. When you click
    the Edit link button the GridView (also Select and Delete) the RowCommand
    event is called.

    In there can do this:
    if (e.CommandName == "Edit")
    {
    Session["RowSelected"] = Convert.ToInt32(e.CommandArgument);
    }

    e.CommandArguement gives you the row number and i just add this to the
    session variable and later when your in the SelectedIndex Changed event you
    can retrieve the session value like this:

    if(Session["RowSelected"] != null)
    {
    int currentRow = (int)Session["RowSelected"];
    }

    either way you now have the current row number

    Hope this helps!

    "Babu" wrote:

    > I am having DropDownList inside GridView. When the DropDownList SelectedIndex changed a event should fire and how can I able to get the row number for the GridView
    >
    >
     
    John Padilla, Dec 15, 2007
    #2
    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. Dave
    Replies:
    2
    Views:
    7,868
  2. Danny

    dropdown event SelectedIndexChange

    Danny, Apr 21, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    128
    Paulo
    Apr 23, 2004
  3. Randy
    Replies:
    4
    Views:
    175
    Jeffrey Tan[MSFT]
    Sep 23, 2003
  4. sharmasu

    SelectedIndexChange event handling for tabstrip control.

    sharmasu, Apr 26, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    243
    sharmasu
    Apr 26, 2004
  5. Phil

    Help - Treeview - SelectedIndexChange Event

    Phil, Apr 29, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    283
Loading...

Share This Page