我将Gridview设置为自动生成columns = true我已为某些columna nd页脚创建了一些动态文本框现在我点击页脚按钮gridview rowcomand事件未被触发,要触发此命令我必须再次绑定gridview但当我绑定我的值时,我在文本框中发生了变化.. 以下是我的代码rowdatabound事件
protected void grdMaterialPercentage_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (grdMaterialPercentage.AutoGenerateColumns == true)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Visible = false;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Visible = false;
if (DataBinder.Eval(e.Row.DataItem, "AgentName").ToString() != string.Empty)
{
int i = 0;
foreach (TableCell c in e.Row.Cells)
{
if (i >= 3)
{
TextBox tb = new TextBox();
tb.Text = c.Text;
tb.ID = "txtbox" + i.ToString();
tb.Style.Add("Width", "25px");
tb.Style.Add("Height", "15px");
c.Controls.Clear();
c.Controls.Add(tb);
}
i++;
}
}
else
{
e.Row.Visible = false;
}
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Visible = false;
int j = 0;
foreach (TableCell c in e.Row.Cells)
{
if (j >= 3)
{
DataRow dr = dt.Rows[dt.Rows.Count - 1];
LinkButton btn = new LinkButton();
btn.ID = "FooterButton" + j.ToString();
btn.CommandName = j.ToString();
btn.Text = "Save" + dr[j - 1].ToString();
btn.CssClass = "button";
btn.Style.Add("align", "center");
btn.CommandArgument = dr[j - 1].ToString();
btn.OnClientClick = "return ValidateTotalPercentage('" + j + "')";
c.Controls.Clear();
c.Controls.Add(btn);
} j++;
}
}
}
}
答案 0 :(得分:0)
我建议您使用Firebug等工具,在点击网格上的链接时,使用Javascript查看引擎盖下发生的情况。这就是我要穿的鞋子。