I have a WHDG that is bound to a dataset and has one TemplateDataField and one ItemTemplate with an ImageButton. I am setting the CommandArgument of the ImageButton to the value of a column in my data source. I can set it to any column in that dataset except the column that is referenced in the DataKeyFields property of the grid. When I use that column, which is the primary key of the dataset, the CommandArgument that I get server side is a negative (-) number and is not the proper value of that record. It appears to be the index of the row that contains the imagebutton.
Server Side Handler
protected
void btnGoClientDetails_Command(object sender, EventArgs e)
{
ImageButton img = (ImageButton)sender;
WorkItemPCNId =
Convert.ToInt32(img.CommandArgument);
}
Grid code
<
>
="true">
/>
="30px">
...
Figured it out myself. Was a problem with the dataset. Not the grid.