Member 11644373 Ответов: 0

Как использовать ajax в представлении сетки


Привет всем я использую сетку для отображения данных из базы данных и я хочу всякий раз когда я нажимаю на кнопку generate она отображает ГИРД поэтому я использовал тег update panel на странице aspx но он работает в первый раз у меня есть три текстовых поля и одна кнопка первый раз он выбирает значения в текстовом поле и при нажатии на кнопку он отображает сетку с данными но снова я выбираю значение в текстовом поле

Что я уже пробовал:

 <asp:UpdatePanel runat="server"><ContentTemplate>
    <%--<asp:Panel ID="pnlDetails" runat="server" CssClass="ReportTFS" ScrollBars="Auto" Style="margin-bottom: 0px" Width="1170px">--%>
      <asp:GridView ID="gvDetails" runat="server" ShowFooter="True" Style="width: 100%" CssClass="grid clsWrap" AutoGenerateColumns="False" Width="980px" OnRowDataBound="gvDetails_RowDataBound" >
       <Columns>
              <asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="Task Name" ItemStyle-Width="90px" ControlStyle-Width="90px">
                <ItemTemplate>
                    <asp:Label ID="lbltaskdescription" runat="server" Text='<%# Bind("TaskName") %>' Width="90px"></asp:Label>
                </ItemTemplate>
                <%--<HeaderStyle CssClass="gridB" />--%>

                <ControlStyle Width="90px"></ControlStyle>

                <HeaderStyle CssClass="gridB"></HeaderStyle>
              <ItemStyle Width="90px"></ItemStyle>
            </asp:TemplateField>
             
            <asp:BoundField DataField="Date" HeaderText="CreatedDate" ReadOnly="true" ItemStyle-Width="83px" ControlStyle-Width="80px">
                <ControlStyle Width="80px"></ControlStyle>

                <HeaderStyle CssClass="gridB" />

                <ItemStyle Width="83px"></ItemStyle>
            </asp:BoundField>
           
          <%--  <asp:BoundField DataField="Date" HeaderText="CreatedDate" ReadOnly="true" ItemStyle-Width="50px" ControlStyle-Width="50px">
                <ControlStyle Width="75px"></ControlStyle>

                <HeaderStyle CssClass="gridB" />

                <ItemStyle Width="74px"></ItemStyle>
            </asp:BoundField>--%>

              <asp:BoundField DataField="Subject" HeaderText="Description" ReadOnly="True" ItemStyle-Width="200px" ControlStyle-Width="200px">
                <ControlStyle Width="200px"></ControlStyle>

                <ItemStyle Width="200px"></ItemStyle>
            </asp:BoundField>

                <asp:BoundField DataField="employeename" HeaderText="AssignedTo" ReadOnly="True" ItemStyle-Width="85px" ControlStyle-Width="80px" Visible="false">
                <ControlStyle Width="80px"></ControlStyle>

                <ItemStyle Width="85px"></ItemStyle>
            </asp:BoundField>
          

            <%--<asp:BoundField DataField="employeename" HeaderText="Employee Name" ReadOnly="True" ItemStyle-Width="110px" ControlStyle-Width="110px">
                <ControlStyle Width="110px"></ControlStyle>

                <ItemStyle Width="130px"></ItemStyle>
            </asp:BoundField>--%>


              <asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="Efforts" ControlStyle-Width="100px">
                  <ControlStyle Width="40px"></ControlStyle>
                <EditItemTemplate>
                   <%-- <asp:TextBox ID="txtwh" runat="server" Text='<%# Bind("normal_working_hours") %>' Width="40px" style="text-align:center"></asp:TextBox>--%>
                    <%--<asp:RangeValidator ID="rgvWH2" runat="server" ControlToValidate="txtwh" ErrorMessage="Please provide valid hours b/w 0-8" ForeColor="Red" MaximumValue="8" MinimumValue="0" Type="Double"></asp:RangeValidator>--%>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Lbleffort" runat="server" Text='<%# Bind("EffortsInHours") %>' Width="40px" style="text-align:center"></asp:Label>
                </ItemTemplate>
                <ItemStyle Width="80"></ItemStyle>
                <HeaderStyle CssClass="gridB"></HeaderStyle>
            </asp:TemplateField>


            <asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="Logged Hours" ControlStyle-Width="100px">
                <EditItemTemplate>
                   <%-- <asp:TextBox ID="txtwh" runat="server" Text='<%# Bind("normal_working_hours") %>' Width="40px" style="text-align:center"></asp:TextBox>--%>
                    <%--<asp:RangeValidator ID="rgvWH2" runat="server" ControlToValidate="txtwh" ErrorMessage="Please provide valid hours b/w 0-8" ForeColor="Red" MaximumValue="8" MinimumValue="0" Type="Double"></asp:RangeValidator>--%>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("LoggedHours") %>' Width="40px" style="text-align:center"></asp:Label>
                </ItemTemplate>

                <FooterTemplate>
                    <asp:Label ID="lblnormal_working_hours" Font-Bold="true" runat="server"></asp:Label>
                </FooterTemplate>
                <%--<HeaderStyle CssClass="gridB" />--%>

                <ControlStyle Width="40px"></ControlStyle>
                <ItemStyle Width="80"></ItemStyle>
                <HeaderStyle CssClass="gridB"></HeaderStyle>
            </asp:TemplateField>

            <%--<asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="Description" ControlStyle-Width="150px">
                <EditItemTemplate>
                    <asp:TextBox ID="txtDesc" runat="server" Text='<%# Bind("description") %>' Width="200px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("description") %>' Width="150px"></asp:Label>
                </ItemTemplate>
                <ControlStyle Width="150px"></ControlStyle>

                <HeaderStyle CssClass="gridB"></HeaderStyle>
            </asp:TemplateField>--%>

            
              <%-- not <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("project") %>' Width="100px"></asp:Label>
                </ItemTemplate>--%>
                <%--not<HeaderStyle CssClass="gridB" />--%>

              <asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="Remarks" ItemStyle-Width="380px" ControlStyle-Width="380px" Visible="false">

                <ItemTemplate>
                    <asp:Label ID="lblremark" runat="server" Text='<%# ((string)Eval("Remarks"))%>'>' Width="380px"></asp:Label>
                </ItemTemplate>
                <%--<HeaderStyle CssClass="gridB" />--%>

                <ControlStyle Width="380px"></ControlStyle>

                <HeaderStyle CssClass="gridB"></HeaderStyle>
              <ItemStyle Width="380px"></ItemStyle>
            </asp:TemplateField>

            <asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="EmployeeName" ItemStyle-Width="380px" ControlStyle-Width="380px" Visible="false">

                <ItemTemplate>
                    <asp:Label ID="empname" runat="server" Text='<%# (Eval("employeename")) %>'>' Width="380px"></asp:Label>
                </ItemTemplate>
                <%--<HeaderStyle CssClass="gridB" />--%>

                <ControlStyle Width="380px"></ControlStyle>

                <HeaderStyle CssClass="gridB"></HeaderStyle>
              <ItemStyle Width="380px"></ItemStyle>
            </asp:TemplateField> 

          <%--  <asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="Phase" ControlStyle-Width="70px">
                <EditItemTemplate>
                    <asp:Label ID="lblphs" runat="server" Text='<%# Bind("phase") %>' Visible="false" Width="70px"></asp:Label>
                    <asp:DropDownList ID="ddlphs" runat="server" Width="70px">
                    </asp:DropDownList>
                </EditItemTemplate>--%>
               <%--not <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("phase") %>' Width="70px"></asp:Label>
                </ItemTemplate>--%>
                <%--not<HeaderStyle CssClass="gridB" />--%>

               <%-- <ControlStyle Width="70px"></ControlStyle>

                <HeaderStyle CssClass="gridB"></HeaderStyle>
            </asp:TemplateField>--%>

           <%-- <asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="Overtime" ControlStyle-Width="70px">
                <EditItemTemplate>
                    <asp:TextBox ID="txtov" runat="server" Text='<%# Bind("overtime") %>' Width="70px"></asp:TextBox>--%>
                    <%--not<asp:RangeValidator ID="rgOV2" runat="server" ControlToValidate="txtov" ErrorMessage="Please provide valid hours b/w 0-8" ForeColor="Red" MaximumValue="8" MinimumValue="0" Type="Double"></asp:RangeValidator>--%>
              <%--  </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("overtime") %>' Width="70px" style="text-align:center"></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:Label ID="lbl_overtime" Font-Bold="true" runat="server"></asp:Label>
                </FooterTemplate>--%>
                <%--not<HeaderStyle CssClass="gridB" />--%>

               <%-- <ControlStyle Width="70px"></ControlStyle>

                <HeaderStyle CssClass="gridB"></HeaderStyle>
            </asp:TemplateField>--%>
<%--            <asp:TemplateField HeaderStyle-CssClass="gridB" HeaderText="Additional Information" ControlStyle-Width="70px">
                <EditItemTemplate>
                    <asp:TextBox ID="txtaI" runat="server" Text='<%# Bind("additional_info") %>' Width="170px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("additional_info") %>' Width="170px"></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                    <span style="color: orange">Totalhours - </span>
                    <asp:Label ID="lbladditional_info" Font-Bold="true" runat="server"></asp:Label>
                </FooterTemplate>--%>
                <%--not<HeaderStyle CssClass="gridB" />--%>

<%--                <ControlStyle Width="70px"></ControlStyle>

                <HeaderStyle CssClass="gridB"></HeaderStyle>
            </asp:TemplateField>--%>
        </Columns>
        <HeaderStyle Font-Bold="False" CssClass="Font gvheaderstyle" Wrap="False" />
        <PagerStyle CssClass="gridB" ForeColor="WhiteSmoke" />
        <RowStyle HorizontalAlign="Center" />
        <FooterStyle CssClass="gridB" HorizontalAlign="Center" />
    </asp:GridView>
    </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAssign_Click" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>

0 Ответов