Вы можете попробовать использовать атрибут OnRowDataBound, чтобы сделать что-то вроде этого
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
//HeaderStuff
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
ObjectTye objectType = (ObjectType)e.Row.DataItem;
// and doing some stuff with the properties
e.Row.Cells[0].Text = objectType.SomeProperty.ToString();
LinkButton deleteLnk = (LinkButton)e.Row.FindControl("lnkDelete");
deleteLnk.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete this')");
deleteLnk.CommandArgument = e.Row.RowIndex.ToString();
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
int rowIndex = int.Parse(e.CommandArgument.ToString());
GridViewRow row = GridView1.Rows[rowIndex];
ObjectType objectType = new ObjectType();
objectType.StringProperty = row.Cells[0].Text;
}