我有一个与数据库相关的GridView。这是一个数据绑定:
protected void GridViewProgramms_SelectedIndexChanged(object sender, EventArgs e)
{
int rowIndex = ((GridView) sender).SelectedIndex;
var programid = ((GridView) sender).Rows[rowIndex].Cells[1].Text;
GridViewEx.RowEditing += GridViewEx_RowEditing;
SqlDataSource1.SelectParameters["ID"].DefaultValue = programid;
GridViewEx.DataBind();
ExcersicePanel.Visible = true;
PanelAp.Visible = false;
}
一切正常,但我需要在GridView中更改一些单元格值。我需要重写最后一行中的每个Cell。如何做到这一点而不影响数据库?
答案 0 :(得分:0)
数据绑定后,您需要在gridview的RowDataBound
事件中编写代码(更改单元格文本)
有关更多说明,请参阅以下链接
答案 1 :(得分:0)
protected void GridViewEx_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
label or textbox ddltype = (label or textbox)e.Row.FindControl("id");
ddltype.text="ur text";
}
}