折叠列中的数据表控件具有空值

时间:2018-01-09 09:17:19

标签: c# asp.net gridview datatables

我有一个包含很多列的数据表。 当我调整屏幕大小时,某些列会以这种方式折叠

这是我用来构建gridview的HTML代码

<asp:GridView runat="server" ID="gridView" CssClass="table table-striped table-bordered"   AutoGenerateColumns="false" OnRowDataBound="gridView_RowDataBound" style="width:100% !important;">
                <Columns>
                    <asp:TemplateField HeaderText ="Salva" ItemStyle-Width="5%">
                        <ItemTemplate>                                
                            <asp:LinkButton runat="server" ID="lnkBtnModifica" CssClass="btn btn-primary" CommandArgument="<%# Container.DataItemIndex %>" onclick="lnkBtnModifica_Click"><i class="fa fa-floppy-o"></i></asp:LinkButton>                                
                        </ItemTemplate>                             
                    </asp:TemplateField> 
                    <asp:BoundField runat="server" HeaderText="ID" DataField="ID_Product" ItemStyle-Width="3%"/>                        
                    <asp:BoundField runat="server" HeaderText="Nome" DataField="ProductName" ItemStyle-Width="25%"/>  
                    <asp:BoundField runat="server" HeaderText="Giacenza" DataField="ProductStock" ItemStyle-Width="5%" />
                    <asp:BoundField runat="server" HeaderText="Codice" DataField="ProductCode" ItemStyle-Width="7%"/>

                    <asp:BoundField runat="server" HeaderText="Stato" DataField="ProductStatus" ItemStyle-CssClass="hidden" HeaderStyle-CssClass="hidden"/>      
                    <asp:TemplateField HeaderText ="Cambia codice" ItemStyle-Width="10%">
                        <ItemTemplate>                                
                            <asp:TextBox runat="server" ID="txtCodice" CssClass="txtSmall form-control" ></asp:TextBox>
                        </ItemTemplate>                             
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText ="Somma qta" ItemStyle-Width="7%">
                        <ItemTemplate>                                
                            <asp:TextBox runat="server" ID="txt_SUM_qta" CssClass="txtSmallInt form-control"></asp:TextBox>
                        </ItemTemplate>                             
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText ="Sottrai qta" ItemStyle-Width="7%">
                        <ItemTemplate>                                
                            <asp:TextBox runat="server" ID="txt_SUB_qta" CssClass="txtSmallInt form-control"></asp:TextBox>
                        </ItemTemplate>                             
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText ="Sostituisci qta" ItemStyle-Width="7%">
                        <ItemTemplate>                                
                            <asp:TextBox runat="server" ID="txt_REP_qta" CssClass="txtSmallInt form-control"></asp:TextBox>
                        </ItemTemplate>                             
                    </asp:TemplateField>


                     <asp:TemplateField HeaderText ="Stato" ItemStyle-Width="10%">
                        <ItemTemplate>                                
                            <asp:DropDownList runat="server" ID="ddl_Stato" CssClass="form-control"></asp:DropDownList>
                        </ItemTemplate>                             
                    </asp:TemplateField>

                     <asp:TemplateField HeaderText ="Note" ItemStyle-Width="10%">
                        <ItemTemplate>                                
                            <asp:TextBox runat="server" ID="txt_Note" CssClass="form-control" TextMode="MultiLine" Rows="1" MaxLength="500"></asp:TextBox>
                        </ItemTemplate>                             
                    </asp:TemplateField>             


                    <asp:BoundField runat="server" HeaderText="ID_Product"  ItemStyle-CssClass="hidden" HeaderStyle-CssClass="hidden" DataField="ID_Product" />                        

                </Columns>

            </asp:GridView>

这是使数据表工作的javascript代码

<script>

    $('#<%=gridView.ClientID%>').dataTable({
        dom: "Bfrtip",
        buttons: [
          {
              extend: "copy",
              className: "btn-sm"
          },
          {
              extend: "csv",
              className: "btn-sm"
          },
          {
              extend: "excel",
              className: "btn-sm"
          },
          {
              extend: "pdfHtml5",
              className: "btn-sm"
          },
          {
              extend: "print",
              className: "btn-sm"
          },
        ],
        responsive: true,
        'pageLength': 1000,
        stateSave : true
    });
</script>

问题在于,当我保存行时,即使我填充了TextBox.Text也是空的。

 protected void lnkBtnModifica_Click(object sender, EventArgs e)
    {
        String sModifica = "";
        int rowIndex = Convert.ToInt32(((LinkButton)sender).CommandArgument);
        int ID = Convert.ToInt32(gridView.Rows[rowIndex].Cells[gridView.Rows[rowIndex].Cells.Count - 1].Text);

        TextBox txt = (TextBox)gridView.Rows[rowIndex].FindControl("txt_Note");            
        String note = txt.Text; -->EMPTY

这里是gridview的图像。正常和折叠视图 Normal Collapsed

0 个答案:

没有答案