<asp:GridView ID="gvSections" runat="server" AutoGenerateColumns="false" CssClass="Grid" DataKeyNames="section_id" Width="80%" Style="padding-left: 100px"> <asp:TemplateField ItemStyle-VerticalAlign="Top" ItemStyle-HorizontalAlign="Justify"> <asp:ImageButton ID="imgShow" runat="server" OnClick="Show_Hide_ChildGrid" ImageUrl="~/Images/plusicon.png" CommandArgument="Show" /> <asp:Label ID="lblSectionDis" runat="server" Text='<%# Bind("section_name") %>' Font-Bold="true" Style="font-size: 16px;"> <asp:Panel ID="pnlOrders" runat="server" Visible="false" Style="position: relative"> <asp:GridView ID="gvQuestionAnswer" runat="server" AllowSorting="False" BorderWidth="2px" CellPadding="2" ForeColor="Black" GridLines="None" Width="100%" AutoGenerateColumns="false" OnRowDataBound="gvQuestionAnswer_RowDataBound" AllowPaging="True" OnPageIndexChanging="gvQuestionAnswer_PageIndexChanging" PageSize="5"> <asp:TemplateField HeaderStyle-Width="50" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Center"> <%# Container.DataItemIndex+1 %> <asp:TemplateField HeaderText="Question No" HeaderStyle-HorizontalAlign="Left" Visible="false"> <asp:Label ID="lblQuestionId" runat="server" Text='<%# Bind("question_id") %>' Width="150"> <asp:TemplateField HeaderStyle-HorizontalAlign="Left"> <asp:Label ID="lblSectionnew" runat="server" Text='<%# Bind("section_name") %>' Width="700" Visible="false"> <asp:Label ID="lblSectionId" runat="server" Text='<%# Bind("section_id") %>' Visible="false"> <asp:Label ID="lblQuestion" runat="server" Text='<%# Bind("qm_desc") %>'> <asp:TextBox ID="txtAnswer" runat="server" TextMode="MultiLine" Width="450" Text='<%# Bind("Answer") %>'> <asp:RequiredFieldValidator ID="RR1" runat="server" ControlToValidate="txtAnswer" Display="None" ValidationGroup="sub" ErrorMessage="Please Enter Answer" ForeColor="Red" SetFocusOnError="true"> <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender13" runat="server" Enabled="True" TargetControlID="RR1"> <asp:BoundField ItemStyle-Width="150px" DataField="section_id" HeaderText="Section Id" Visible="false" /> <asp:BoundField ItemStyle-Width="150px" DataField="section_name" HeaderText="Section Name" Visible="false" />
protected void gvQuestionAnswer_PageIndexChanging(object sender, GridViewPageEventArgs e) { try { DataTable dtpageindex = new DataTable(); dtpageindex = ViewState["SectionQuestions"] as DataTable; gvSections.PageIndex = e.NewPageIndex; string strSection; string strAnswer; string strQuestionid; foreach (GridViewRow row in gvSections.Rows) { if (row.RowType == DataControlRowType.DataRow) { GridView gv = row.FindControl("gvQuestionAnswer") as GridView; foreach (GridViewRow gvrow in gv.Rows) { if (gvrow.RowType == DataControlRowType.DataRow) { Label lblQuestionId = gvrow.FindControl("lblQuestionId") as Label; Label lblSectionId = gvrow.FindControl("lblSectionId") as Label; TextBox txtAnswer = gvrow.FindControl("txtAnswer") as TextBox; strAnswer = txtAnswer.Text; strQuestionid = lblQuestionId.Text; foreach (DataRow dr in dtpageindex.Rows) { if (dr["question_id"].ToString() == strQuestionid) { dr["Answer"] = strAnswer; dtpageindex.AcceptChanges(); } } } } ViewState["SectionQuestions"] = dtpageindex; gv.PageIndex = e.NewPageIndex; gv.DataSource = dtpageindex; gv.DataBind(); } } } catch (Exception ex) {} }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)