I have an SPGridView with RowCommand event handler defined to handle link events from the grid view. I have a ButtonField on every row defined with CommandName and DataTextField. When my event handler is called though, the argument is always the row index as opposed to the value I passed in datatable for the column specified (which has an integer) for DataTextField. With this, I am unable to figure out the actual data row the link was clicked for, since my data may have changed between the initial render and the postback.
currently the postback link at client side has __doPostBack('<gridid>', '<command>$<rowindex>'), which obviously is missing the DataTextField I had passed.
Is there any way to make the ButtonField include more arguments than just the row index? Basically, I need to be able to add another integer to the argument list that I can retrieve in the command handler. Even some way to override the postback link is acceptable too.
Thanks, raja.
Additional Info:
the creation of gridview is happening in the C# code that doesn't have an ascx part to it.
C# code does something like this:
OnInit: var gridview = new SPGridView { set properties: EnableViewState, ShowHeader, AutoGenerateColumns, AllowSorting, GridLines, Width, CellPadding }); gridview.Columns.Add(new HyperLinkField { set properties: HeaderText, DataTextField, DataNavigateUrlFields, and DataNavigateUrlFormatString }); gridview.Columns.Add(new ButtonField { set properties: HeaderText, DataTextFormatString, CommandName="delete", DataTextField="feedid" });// I expect "feedid" column value from my datatable to show up as the command argument! but it's ignored and I get the row index instead gridview.RowCommand += RowCommandHandler; Controls.Add(gridview); OnLoad: gridview.DataSource = new DataView(table); gridview.DataBind(); raja.