1
我需要使用sqldatasource(存儲過程)來綁定gridview。背後SqlDataSource自定義分頁
<asp:GridView ID="gvBC" runat="server" AutoGenerateColumns="False" ShowFooter="True" AllowSorting="True" AllowPaging="True" pageSize ="3" DataSourceID="dsBCSearch">
<Columns>
<asp:BoundField DataField="ContactID" HeaderText="ContactID" Visible="false"/>
<asp:BoundField DataField="BldgNum" HeaderText="Bldg#" SortExpression="BldgNum" />
</Columns>
<EmptyDataTemplate> No Building Coordinator Found. </EmptyDataTemplate>
<EmptyDataRowStyle HorizontalAlign="Center" />
</asp:GridView>
<asp:SqlDataSource ID="dsBCSearch" runat="server" ConnectionString="<%$ ConnectionStrings:DBConnStr %>" SelectCommand="GetBC" SelectCommandType="StoredProcedure"
SortParameterName="SortExpression" />
代碼:
protected void Page_Load(object sender, EventArgs e)
{
LoadBC();
}
protected void LoadBC()
{
dsBCSearch.SelectCommand = "GetBCwP";
dsBCSearch.SelectParameters.Clear();
dsBCSearch.SelectParameters.Add("LName", this.txtLNAme.Text.Trim());
dsBCSearch.SelectParameters.Add("Active", this.chkActive.Checked.ToString());
//dsBCSearch.SelectParameters.Add("sortExpression", this.gvBC.SortExpression);
dsBCSearch.SelectParameters.Add("startRowIndex", this.gvBC.PageIndex.ToString());
dsBCSearch.SelectParameters.Add("maximumRows", this.gvBC.PageSize.ToString());
this.gvBC.DataBind();
}
現在只呈現第一頁(3條)和頁腳沒有號碼顯示出來。你可以給頁腳添加分頁嗎?
謝謝