<asp:TemplateField HeaderText="使用产品" ItemStyle-Width="150px">
<ItemTemplate>
<%#Eval("production")%>
</ItemTemplate>
<EditItemTemplate>
<asp:Table runat="server" ID="productionTB" Width="150px"></asp:Table>
</EditItemTemplate>
</asp:TemplateField>
我在GridView的一个cell里放了个table然后在后台给它添了值
((Table)(GridViewClient.Rows[e.NewEditIndex].Cells[7].Controls[1])).Rows.Add(tr);
但是在用的时候table里面为空了
Table tb = (Table)(GridViewClient.Rows[e.RowIndex].Cells[7].Controls[1]);
求正解啊
<ItemTemplate>
<%#Eval("production")%>
</ItemTemplate>
<EditItemTemplate>
<asp:Table runat="server" ID="productionTB" Width="150px"></asp:Table>
</EditItemTemplate>
</asp:TemplateField>
我在GridView的一个cell里放了个table然后在后台给它添了值
((Table)(GridViewClient.Rows[e.NewEditIndex].Cells[7].Controls[1])).Rows.Add(tr);
但是在用的时候table里面为空了
Table tb = (Table)(GridViewClient.Rows[e.RowIndex].Cells[7].Controls[1]);
求正解啊
if(e.Row.RowType == DataControlRowType.DataRow) {
if(e.Row.RowIndex == GridView1.EditIndex)
{
((Table)(GridViewClient.Rows[e.Row.RowIndex].Cells[7].Controls[1])).Rows.Add(tr);
}Table tb = (Table)(GridViewClient.Rows[e.RowIndex].Cells[7].Controls[1]);
在GridView1_RowUpdating事件中用
处理写完后
GridView1.EditIndex = -1;
e.Cancel = true;处理下
这个我是放在GridViewClient_RowEditing里面的出这个事件时还是有值得
等到了GridViewClient_RowUpdating就没值了
根据.FindControl("") 先找出控件,然后再对他进行操作,
((Table)(GridViewClient.Rows[e.NewEditIndex].Cells[7].Controls[1])).Rows.Add(tr);
Cells[7].Controls[1]))你这样写不能说不对,对着呢 但是这样写容易出错 建议你还是写全!
根据.FindControl("") 先找出控件 再对他进行操作,
((Table)(GridViewClient.Rows[e.NewEditIndex].Cells[7].Controls[1])).Rows.Add(tr);
Cells[7].Controls[1]))你这样写不能说不对 但是这样写容易出错 建议你还是写全!