I created new ASP GridView and customize it without select DataSource.
and create SqlDataSource (define connectionstring, parameters) .
then assign GridView DataSource programmatically in my .CS File .. and it's work very well.
But when moving between GridView Pages the gridview disappear and do nothing...
<asp:GridView ID="gridAdminRoles" runat="server"
DataKeyNames="RoleID" CellPadding="4"
ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"
ShowFooter="True" Width="100%" AllowPaging="True" PageSize="7"
onpageindexchanging="gridAdminRoles_PageIndexChanging" >
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="RoleID" HeaderText="RoleID" />
<asp:BoundField DataField="RoleName" HeaderText="Name" />
<asp:BoundField DataField="BranchName" HeaderText="Branch" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="RolesDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ShareCon %>"
SelectCommand="GetBranchesRoles"
SelectCommandType="StoredProcedure" >
</asp:SqlDataSource>
In Page_Load() Event...
gridAdminRoles.DataSource = RolesDataSource;
gridAdminRoles.DataBind();
All of this working properly |^|
Now i want moving between pages of gridview So i wrote this code into PageIndexChanging but the GridView Disappear ...
protected void gridAdminRoles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridAdminRoles.PageIndex = e.NewPageIndex;
gridAdminRoles.DataBind();
}