【问题标题】:Binding gridview dynamically动态绑定gridview
【发布时间】:2014-04-23 05:57:32
【问题描述】:

我在页面加载时绑定了我的 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>

【问题讨论】:

标签: c# asp.net


【解决方案1】:

您可以使用 AJAX 来做到这一点。困难的部分是下面收集的行的 EDIT 和 DELETE 函数。

可以在here 找到有关执行此操作的详细教程。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多