Link to home
Start Free TrialLog in
Avatar of wolfcoop
wolfcoop

asked on

Template Field in gridview that fires drop down selected index changed event getting row index

I have a template field in the item template of a gridview.  The template field is a status dropdownlist that fires an onindexchanged event for the drop down.  I need to reference the row index of the row that fired the drop down on index changed.

Nothing chages in the gridview so I cant reference the datakey, or use the row event args cause it is a template field off of the item template.  No row is selected, so is there a way to get that information his way???

Please help
Protected Sub drpStatus_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
 
        Dim strStatus as String = sender.SelectedValue
        Dim strID as String = Gridiew1.SelectedRow.Items.cells(0)
        or something like
        Dim strID as String =  GridView1.SelectedDataKey
 
 
    End Sub

Open in new window

Avatar of cdaly33
cdaly33
Flag of United States of America image

If you need the index then you should be able to cast the sender as a dropdownlist and grab the selectedindex

 Dim ddl As DropDownList = CType(sender, DropDownList)
 dim theindex as int32 =  ddl.SelectedIndex

Avatar of wolfcoop
wolfcoop

ASKER

No I need the row index, not the selected index of the drop down.  I can get that by sender.selectedindex.  I need to reference the Row index so I know what ID to update in the DB with the new status value from the drop down.  In other words I eitherneed to reference the first cell in the row that held the drop down that fired the onselectedindexchanged event, who ate the spider to eat the fly.
Sorry for the misread the first time.  If it was me I'd go a bit different direction with it.  I'd do a javascript function that calls a PageMethod which fires when the drop down fires and passes both the row index and selected value.  Let me know if this is a possibility for your app.
sure so you have sample code?  Basically that is exactly what I need.
Can you have a static drop down or is the drop down loaded from a database?  Either way it would be at least tomorrow until I have code.

the procedure is going to be like this and the only variable is what fires the initial call
http://www.geekzilla.co.uk/View30F417D1-8E5B-4C03-99EB-379F167F26B6.htm
ASKER CERTIFIED SOLUTION
Avatar of wolfcoop
wolfcoop

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial