Dropdown Inside Gridview SelectedIndexChange Event

B

Babu

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
 
J

John Padilla

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!
 

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,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top