动态绑定gridview

时间:2014-04-23 05:57:32

标签: c# asp.net

我在页面加载时绑定了我的gridview,但是当用户向下滚动时我希望数据绑定。

我使用存储过程来绑定gridview

当用户在每10行后向下滚动时,如何动态地在gridview中绑定行?

<asp:GridView ID="GridViewUserSkillQuery" runat="server" AutoPostBack="True" AutoGenerateColumns="false" Width="100%" RowStyle-ForeColor="Black" GridLines="None" OnDataBound="GridViewUserSkillQuery_DataBound">
    <RowStyle ForeColor="Black"></RowStyle>
      <Columns>
          <asp:TemplateField>
            <ItemTemplate>
                  <div class="box">
                       <div class="image">
                            <asp:Image ID="imguser" runat="server" Width="60px" Height="60px" CssClass="user_image" AlternateText="image not found"                                                        ImageUrl='<%# Bind("Image") %>' />
                             <div class="user_profession"> 
                                <asp:Label ID="lblProfession" Font-Size="10px" ForeColor="#752F8E" runat="server"                                                  Text="student"></asp:Label>
                                                   <%-- Text='<%# Bind("Profession") %>'--%>  </div>
                              </div>
                              <div class="box2">
                                  <div class="name">
                                     <asp:LinkButton ID="lbtnUsername" Font-Overline="false" runat="server" Text='<%# Bind("Name") %>'                                                             ForeColor="#752F8E" OnClick="lbtnUsername_Click"></asp:LinkButton>

                                     <asp:Label ID="lblQuser" runat="server" Text='<%# Bind("Uid") %>' Visible="false"></asp:Label>
                                   </div>
                                   <div class="category">  related to:
                                     <asp:Label ID="lblskillname" runat="server" Text='<%# Bind("SkillName") %>' ForeColor="#752F8E"></asp:Label>
                                   </div>
                                   <div class="time">
                                                    (
                                     <asp:Label ID="lblDatetime" runat="server" Font-Size="12px" Text='<%# Bind("EntryDate") %>'></asp:Label>
                                                    )
                                  </div>
                                  <div class="count">
                                        <asp:Label ID="lblanscount" runat="server" Text='<%# Bind("AnsCount") %>' ForeColor="#752F8E"></asp:Label><br />
                                                    Answer
                                  </div>
                              </div>
                              <div class="box3">
                                     <div class="title">
                                                    QTitle:
                                                    <asp:LinkButton ID="lbltitle" runat="server" Text='<%# Bind("Title") %>' OnClick="lbltitle_click"
                                                        ForeColor="Gray"></asp:LinkButton>
                                                </div>
                                                <div class="query">
                                                  <div class="q">Q:</div>
                                                    <asp:Label ID="lblQuery" runat="server" Text='<%# Bind("Query") %>'></asp:Label>
                                                    <asp:Label ID="lblQueryID" runat="server" Text='<%# Bind("QueryID") %>' Visible="false"></asp:Label>
                                                </div>
                                 </div>
                                 <div class="box4">
                                                <div class="reply">

                                                    <asp:Button ID="btnAnswer" runat="server" Text="Answer the Query" OnClick="lbltitle_click"
                                                         CssClass="in_button" ForeColor="White" />
                                                </div>
                                            </div>
                                  </div>
              </ItemTemplate>
            </asp:TemplateField>
     </Columns>
   </asp:GridView>

1 个答案:

答案 0 :(得分:0)

您可以使用AJAX执行此操作。对此的困难部分是下面收集的行的EDIT和DELETE函数。

可以找到有关此操作的详细教程here