点击加号,序号自动生成
//点击保存前执行的方法
protected override bool OnPreSave()
{
txtBXRMC.Value = GetUserName(ddlBXRGH.SelectedValue);
txtSHRMC.Value = GetUserName(ddlSHRGH.SelectedValue);
txtPZRMC.Value = GetUserName(ddlPZRGH.SelectedValue);
int xh1 = 0;
foreach (TableRow item in GCJZQK.Rows)
{
xh1 = xh1 + 1;
(item.Cells[1].Controls[0] as TextBox).Text = xh1.ToString().Trim();
}
}
protected void GCJZQK_AddClick(object sender, System.Web.UI.ImageClickEventArgs e)
{
int xh1 = 0;
foreach (TableRow item in GCJZQK.Rows)
{
xh1 = xh1 + 1;
(item.Cells[1].Controls[0] as TextBox).Text = xh1.ToString().Trim();
}
}
前台:
<Tim:TimXGrid ID="GCJZQK" runat="server" AddVisible="true" AllowAdd="true" EditVisible="false" AllowEdit="true"
DeleteVisible="true" AllowDelete="true" CheckBox="False" ShowHeaderWhenEmpty="True" BodyDivHeight="200px" OnAddClick="GCJZQK_AddClick">
<Columns>
<Tim:TimXTextBoxField DataField="U_GLZBMXJD_XH" HeaderText="" Visible="false">
<ItemStyle Width="0px" />
</Tim:TimXTextBoxField>
<asp:templatefield headertext="序号" insertvisible="False">
<ItemStyle HorizontalAlign="Center" Width="50px" />
<HeaderStyle HorizontalAlign="Center" Width="50px" />
<ItemTemplate><%# Container.DataItemIndex+1 %></ItemTemplate>
</asp:templatefield>
</Columns>
</Tim:TimXGrid>