My requirement is to refresh the data on every postback but if I do so my rowcommand event doesnot get fired on link button click in gridview? How I can achieve it?
我的要求是刷新每个回发的数据,但是如果我这样做的话,我的rowcommand事件不会在link按钮上被触发,在gridview中点击?我怎样才能做到呢?
I am changing the row order using jquery and saving the new order in hidden variable. on page postback I get the new order from hidden variable and rebinds the grid with new order.
我正在使用jquery修改行顺序,并将新顺序保存在隐藏变量中。在页面回发中,我从隐藏变量中获取新订单,并使用新订单重新绑定网格。
I need to rebind the grid with new order everytime page postback. postback occurs when I click on edit/delete linkbuttons in grid but the rowcommand event doest not get fired.
每次页面回发时,我都需要用新订单重新绑定网格。当我单击网格中的编辑/删除链接按钮时发生回发,但是rowcommand事件doest不会被触发。
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string order = hdnOrder.Value.ToString();
if (order != string.Empty)
{
ReOrder();
}
}
}
protected void ReOrder()
{
DataTable dt = new DataTable();
if (ViewState["data"] != null)
{
dt = (DataTable) ViewState["data"];
string[] order = hdnOrder.Value.Split(',');
for (int i = 0; i < order.Length; i++)
{
DataRow[] keyRows;
keyRows = dt.Select("ID='" + order[i] + "'");
if (keyRows.Length > 0)
{
int index = dt.Rows.IndexOf(keyRows[0]);
dt.Rows[index].SetField("Precedence", i + 1);
}
}
DataView dv = dt.DefaultView;
dv.Sort = "Precedence ASC";
ViewState["data"] = dv.ToTable();
grd.DataSource = ViewState["data"];
grd.DataBind();
hdnOrder.Value = string.Empty;
}
}
1 个解决方案
#1
1
If the following is true:
如果以下是真的:
- You need to process the row command;
- 您需要处理行命令;
- You need to rebind the grid, but have it also reflect the results of the row command
- 您需要重新绑定网格,但也要让它反映行命令的结果
... it ought to be as simple as doing your reorder in the PreRender
event handler rather than the Load
event handler.
…它应该像在PreRender事件处理程序而不是在Load事件处理程序中重新排序一样简单。
#1
1
If the following is true:
如果以下是真的:
- You need to process the row command;
- 您需要处理行命令;
- You need to rebind the grid, but have it also reflect the results of the row command
- 您需要重新绑定网格,但也要让它反映行命令的结果
... it ought to be as simple as doing your reorder in the PreRender
event handler rather than the Load
event handler.
…它应该像在PreRender事件处理程序而不是在Load事件处理程序中重新排序一样简单。