如何將下面的代碼從GridView更改爲RadGrid?下面是我的GridView的代碼:將GridView轉換爲RadGrid
protected void gv_Movie_RowCommand(object sender, GridViewCommandEventArgs e)
{
//get the row number of the selected row
int rowNo = int.Parse(e.CommandArgument.ToString());
//get the selected row
GridViewRow row = gv_Movie.Rows[rowNo];
//Get movie ID, which is on the 1st column of the gridview
string movieID = row.Cells[0].Text;
if (e.CommandName == "Select")
{
Response.Redirect("MovieSelect.aspx?id=" + movieID);
}
else if (e.CommandName == "Update")
{
Response.Redirect("MovieUpdate.aspx?id=" + movieID);
}
}
我嘗試下面的代碼,並沒有在所有因e.CommandArgument
工作。任何解決方案?
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
int rowNo = int.Parse(e.CommandArgument.ToString());
GridDataItem row = RadGrid1.Items[rowNo];
string movieID = row.Cells[0].Text;
if (e.CommandName == "Select")
{
Response.Redirect("movieSelect.aspx?id=" + movieID);
}
else if (e.CommandName == "Delete")
{
Response.Redirect("movieUpdate.aspx?id=" + movieID);
}
}
通過不工作,你是什麼意思?參數應該是一樣的......你還可以加入標記嗎? –
GridView>編輯列>添加按鈕字段>沒有命令參數,但在RadGrid中>編輯列>添加網格按鈕列>有一個命令Arguement。 – user1861753