在 GridView_RowCommand中獲取主鍵的值
protected void GridView_RowCommand(object sender GridViewCommandEventArgs e)
{
int OrderId = ConvertToInt(GridViewDataKeys[ConvertToInt(eCommandArgument)]Value); }
在 GridView_PageIndexChanging中獲取主鍵的值
protected void GridView_PageIndexChanging(object sender GridViewPageEventArgs e)
{
int index=GridViewDataKeys[eNewPageIndex]Value;
}
在 GridView_RowDeleting中獲取主鍵的值
protected void GridView_RowDeleting(object sender GridViewDeleteEventArgs e)
{
int index=GridViewDataKeys[eRowIndex]Value;
}
在 GridView_RowEditing中獲取主鍵的值
protected void GridView_RowEditing(object sender GridViewEditEventArgs e)
{
int index = GridViewDataKeys[eNewEditIndex]Value;
}
在 GridView_RowUpdating中獲取主鍵的值
protected void GridView_RowUpdating(object sender GridViewUpdateEventArgs e)
{
int index = GridViewDataKeys[eRowIndex]Value;
}
在 GridView_RowDataBound中獲取主鍵的值
protected void GridView_RowDataBound(object sender GridViewRowEventArgs e)
{
int index = GridViewDataKeys[eRowRowIndex]Value;
}
From:http://tw.wingwit.com/Article/program/net/201311/13689.html