Mehram
asked on
gridview paging not displaying second page.
Hi,
I am using below mentioned code to display data into gridview. it is showing data of first page excellent. When I clicked on 2 page or any other page the gridview disappear to the web page and webpage blank.
Please help me where I am doing wrong/
<asp:GridView ID="Invoicing" runat="server" AutoGenerateColumns="False "
HeaderStyle-Font-Size="Med ium" HeaderStyle-Font-Italic="t rue" CellPadding="1"
ForeColor="#333333" GridLines="None" Width="908px"
AllowPaging="True" PageSize="12" AllowSorting="True" EnableSortingAndPagingCall backs="Tru e"
OnPageIndexChanging="Invoi cing_PageI ndexChangi ng" >
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
public partial class InvPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
loadGrid();
}
SqlConnection con;
SqlCommand cmd;
DataSet ds;
SqlDataAdapter da;
private void loadGrid()
{
string values = "Select sno=Row_number() Over (Order by InvNo,Date), Date, InvNo, Amt=Sum(Amt), CoCom=Sum(Isnull(CoCom,0)) , MkCom=Sum(Isnull(MkCom,0)) , NPV=Sum(NetPurchasedValue) , FreeStock from tempp Where FreeStock='0' Group by Date, InvNo, FreeStock Order by InvNo,Date";
using (con = new SqlConnection(Configuratio nManager.C onnectionS trings["DL ICCBPL"].C onnectionS tring))
{
cmd = new SqlCommand(values,con);
con.Open();
ds = new DataSet();
da = new SqlDataAdapter(cmd);
da.Fill(ds,"bb");
Invoicing.DataSource = ds;
Invoicing.DataMember = "bb";
Invoicing.DataBind();
con.Close();
}
}
protected void Invoicing_PageIndexChangin g(Object sender, GridViewPageEventArgs e)
{
Invoicing.PageIndex = e.NewPageIndex;
Invoicing.DataBind();
//((GridView)sender).PageI ndex = e.NewPageIndex;
}
}
I am using below mentioned code to display data into gridview. it is showing data of first page excellent. When I clicked on 2 page or any other page the gridview disappear to the web page and webpage blank.
Please help me where I am doing wrong/
<asp:GridView ID="Invoicing" runat="server" AutoGenerateColumns="False
HeaderStyle-Font-Size="Med
ForeColor="#333333" GridLines="None" Width="908px"
AllowPaging="True" PageSize="12" AllowSorting="True" EnableSortingAndPagingCall
OnPageIndexChanging="Invoi
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
public partial class InvPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
loadGrid();
}
SqlConnection con;
SqlCommand cmd;
DataSet ds;
SqlDataAdapter da;
private void loadGrid()
{
string values = "Select sno=Row_number() Over (Order by InvNo,Date), Date, InvNo, Amt=Sum(Amt), CoCom=Sum(Isnull(CoCom,0))
using (con = new SqlConnection(Configuratio
{
cmd = new SqlCommand(values,con);
con.Open();
ds = new DataSet();
da = new SqlDataAdapter(cmd);
da.Fill(ds,"bb");
Invoicing.DataSource = ds;
Invoicing.DataMember = "bb";
Invoicing.DataBind();
con.Close();
}
}
protected void Invoicing_PageIndexChangin
{
Invoicing.PageIndex = e.NewPageIndex;
Invoicing.DataBind();
//((GridView)sender).PageI
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sir, I am asking another question related to gridview to show data on label click to load data accordingly into the gridview. please keep online to assist me.
ASKER
Mode="NumericFirstLast" />