Как поддерживать состояние флажка с помощью in a gridivew при использовании контейнера ajax tab в ASP.NET с помощью C#?
Я хочу поддерживать состояние флажка с помощью gridview при использовании контейнера ajax tab в asp.net с помощью c#. Я установил флажок с помощью сетки, но проверенное состояние приходит как ложное.
Я использую событие activetabindex changed с Auto post true контейнера ajax tab, но состояние флажка в сетке, даже если он установлен, приходит как непроверенный.
<asp:TabContainer ID="tabContainer" runat="server" ActiveTabIndex="0" onactivetabchanged="tabContainer_ActiveTabChanged"> <asp:TabPanel ID="tpnlPresentment" runat="server" HeaderText="Presentment" TabIndex="1"> <ContentTemplate><pre> <cc1:XDataGrid ID="grdDDEnvelope" runat="server" AllowPaging="True" AllowCustomPaging="True" Width="100%" AutoGenerateColumns="False" CssClass="NeST_DATAGRID_FIXED_SIZE" ShowFooter="True" OnPageIndexChanged="grdDDEnvelope_PageIndexChanged" OnItemDataBound="grdDDEnvelope_ItemDataBound" OnPagerClicked="grdDDEnvelope_PagerClicked" OnItemCommand="grdDDEnvelope_ItemCommand" OnSortCommand="grdDDEnvelope_OnSortCommand" AllowSorting="True" PageSize="3"> <AlternatingItemStyle BorderWidth="0px" CssClass="NeST_DATAGRID_CELLDATA2" Wrap="True"> </AlternatingItemStyle> <Columns> <asp:TemplateColumn HeaderText="Sl.No"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.SlNo") %>' ID="Id" /><br /> <input type="hidden" runat="server" id="hidDetailId" name="hidDetailId" value='<%# DataBinder.Eval(Container, "DataItem.OUT_500_FileDetailID") %>' /><asp:ImageButton ID="imgPDF" ToolTip="Click to View Report" CommandName="View" Width="30px" ImageUrl="~/Images/PDF.jpg" runat="server" Visible="false" /></ItemTemplate> <HeaderStyle Width="2%"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Installment Date" HeaderStyle-ForeColor="White" SortExpression="PaymentDate"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.PaymentDate","{0:dd-MMM-yyyy}") %>' ID="PDate" /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="5%"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Created Date"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CreatedDate","{0:dd-MMM-yyyy HH:mm:ss}") %>' ID="PcreatedDate" /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="5%"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Payer Identification Number" HeaderStyle-ForeColor="White" SortExpression="ISNumber"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ISNumber") %>' ID="ISNo" /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="5%"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Type"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.OperationType") %>' ID="ISType" /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="5%"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Claimed Amount" HeaderStyle-ForeColor="White" SortExpression="ClaimedAmount"> <ItemTemplate> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ClaimedAmount","{0:###,####,###.00}") %>' ID="TotalAmount" /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="5%"></HeaderStyle> <ItemStyle HorizontalAlign="Right" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Payer IBAN" HeaderStyle-ForeColor="White" SortExpression="Payer"> <ItemTemplate> <asp:TextBox ID="Payer" runat="server" Style="position: static" CssClass="NeST_GRIDMTEXTBOX" Width="95%" ReadOnly="true" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.Payer") %>' /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="10%"></HeaderStyle> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="DDA Reference No" HeaderStyle-ForeColor="White" SortExpression="MandateReference"> <ItemTemplate> <asp:TextBox ID="DDAReferenceNumber" runat="server" Style="position: static" CssClass="NeST_GRIDMTEXTBOX" Width="98%" ReadOnly="true" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.MandateReference") %>' /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="10%"></HeaderStyle> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Select"> <ItemTemplate> <asp:CheckBox ID="chkEnvelopeSelect" onclick="javascript:CheckUncheck('ctl00_cphDDS_tabContainer_tpnlPresentment_grdDDEnvelope',this);" runat="server"></asp:CheckBox></ItemTemplate> <HeaderTemplate> Select <br /> <asp:CheckBox ID="chkallSelect" runat="server" onclick="javascript:DGSelectOrUnselectAll('ctl00_cphDDS_tabContainer_tpnlPresentment_grdDDEnvelope',this,'chkEnvelopeSelect');" Enabled="true" /></HeaderTemplate> <HeaderStyle Width="2%"></HeaderStyle> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Payer Name"> <ItemTemplate> <asp:TextBox ID="PayerName" runat="server" Style="position: static" CssClass="NeST_GRIDMTEXTBOX" Width="95%" ReadOnly="true" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.PayerName") %>' /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="8%"></HeaderStyle> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Remarks"> <ItemTemplate> <asp:TextBox ID="TxtReason" runat="server" Width="95%" TextMode="MultiLine" CssClass="NeST_MTEXTBOX" MaxLength="1000" Style="position: static" /></ItemTemplate> <HeaderStyle Width="5%" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Paying Bank"> <ItemTemplate> <asp:TextBox ID="PayingBank" runat="server" Style="position: static" CssClass="NeST_GRIDMTEXTBOX" Width="95%" ReadOnly="true" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.PayingBank") %>' /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="7%"></HeaderStyle> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Originator Account No"> <ItemTemplate> <asp:TextBox ID="OriginatorAccountNumber" runat="server" Style="position: static" CssClass="NeST_GRIDMTEXTBOX" Width="94%" ReadOnly="true" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.OriginatorAccountNumber") %>' /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="9%"></HeaderStyle> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Final Beneficiary"> <ItemTemplate> <asp:TextBox ID="FinalBenificaryAccountNo" runat="server" Style="position: static" CssClass="NeST_GRIDMTEXTBOX" Width="94%" ReadOnly="true" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.FinalBenificaryAccountNo") %>' /></ItemTemplate> <HeaderStyle HorizontalAlign="Center" Width="9%"></HeaderStyle> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="NAK/CB Error"> <ItemTemplate> <asp:TextBox ID="TxtNAkError" runat="server" Style="position: static" CssClass="NeST_GRIDMTEXTBOX" Width="94%" ReadOnly="true" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.NAkErrorDescription") %>' /></ItemTemplate> <HeaderStyle Width="5%"></HeaderStyle> <ItemStyle HorizontalAlign="Justify" /> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="Current Status"> <ItemTemplate> <asp:TextBox ID="StatusName" runat="server" Style="position: static" CssClass="NeST_GRIDMTEXTBOX" Width="95%" ReadOnly="true" TextMode="MultiLine" Text='<%# DataBinder.Eval(Container, "DataItem.StatusName") %>' /></ItemTemplate> <HeaderStyle Width="6%"></HeaderStyle> <ItemStyle HorizontalAlign="Justify" /> </asp:TemplateColumn> </Columns> <HeaderStyle CssClass="NeST_DATAGRID_HEADING" HorizontalAlign="Center"></HeaderStyle> <ItemStyle Height="40px" BorderWidth="0px" CssClass="NeST_DATAGRID_CELLDATA" HorizontalAlign="Left"> </ItemStyle> <PagerStyle HorizontalAlign="Left" CssClass="NeST_DATAGRID_CELLDATANEW" Mode="NumericPages" Wrap="True"></PagerStyle> </cc1:XDataGrid>
Что я уже пробовал:
В активной вкладке индекс меняется даже при установке флажка в сетке состояние флажка становится ложным.
List<OUT_500_DETAIL> ListDashboard = new List<OUT_500_DETAIL>(); if ((List<OUT_500_DETAIL>)ViewState["RepEnvelopeGrid"] != null) { ListDashboard = (List<OUT_500_DETAIL>)ViewState["RepEnvelopeGrid"]; } OUT_500_DETAIL objDashboard; int index = -1; for (int i = 0; i < grdRepresentment.Items.Count; i++) { objDashboard = new OUT_500_DETAIL(); objDashboard.OUT_500_FileDetailID = Convert.ToDecimal(((HtmlInputHidden)grdRepresentment.Items[i].FindControl("hidDetailId")).Value); objDashboard.RemarksByBC = ((TextBox)grdRepresentment.Items[i].FindControl("TxtReason")).Text.ToString(); CheckBox chkEnvelopeSelect = (CheckBox)grdRepresentment.Items[i].FindControl("chkRepEnvelopeSelect"); if (chkEnvelopeSelect != null) { try { index = ListDashboard.Select((item, k) => new { Item = item, Index = k }).First(x => x.Item.OUT_500_FileDetailID == objDashboard.OUT_500_FileDetailID).Index; } catch { } if (index != -1) { ListDashboard.RemoveAt(index); } if (chkEnvelopeSelect.Checked) { ListDashboard.Add(objDashboard); } index = -1; } } ViewState["RepEnvelopeGrid"] = ListDashboard;