点击gridview增加按钮,序号自动生成

博客提到点击加号,序号可自动生成,涉及前台相关内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

点击加号,序号自动生成

//点击保存前执行的方法
 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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值