hi , plz help me ..............
how to count to total record in grid view like that "1
-
20
of
65" nd show in footer.
thanks
Loading
Kirtan PatelPosted Aug 12, 2009, 8:25 AM
if you getting error i have recoded it try to Populate data as Following Code Here is way How you will do it
Here is Screen shot How it will Look in Web page in Code I have Done Commenting so that you can understand it Properly and if you dont i have also included Project Files So that You can Take a Reference :)
dont forget to mark "Do you like answer" it will give me some credits :)
Projects File Link is at Bottom of Post Take a Look :)
add name space
using System.Data;
protected void Page_Load(object sender, EventArgs e)
{
//Connecting to Database And Fill it In Grid
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand comm = new SqlCommand("select * From Users", con);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(comm);
da.Fill(ds, "vtable");
GridView1.DataSource = ds.Tables[0];
con.Close();
//Showing Numbers in Label
int iTotalRecords = ((DataTable)(GridView1.DataSource)).Rows.Count;
int iEndRecord = GridView1.PageSize * (GridView1.PageIndex + 1);
int iStartsRecods = iEndRecord - GridView1.PageSize;
if (iEndRecord > iTotalRecords)
{
iEndRecord = iTotalRecords;
}
if (iStartsRecods == 0)
{
iStartsRecods = 1;
}
if (iEndRecord == 0)
{
iEndRecord = iTotalRecords;
}
Label7.Text = iStartsRecods + " to " + iEndRecord.ToString() + " of " + iTotalRecords.ToString();
DataBind();
}
Download Project Files
Suthish NairPosted Mar 3, 2011, 11:53 AM
Kangeyan DPosted Mar 3, 2011, 1:54 AM
urmila kandariPosted Aug 17, 2009, 1:48 AM
thanks for code
Master BillaPosted Aug 12, 2009, 4:39 AM
Add gridview in your page and make all the necessary setting to gridview in and follow the steps here
Note:my code render record in fast and easy
1 Create SP
2.Then write cdoe in your code behind to get the data calculate total row count
and all
3.add a support method also
}
4.you can use the two button to navigate record other than gridview paze navigation
Above code is most efficient way to do the paging.
check more details here
thank you
urmila kandariPosted Aug 12, 2009, 3:36 AM
thanks 4 help but this code is not working
pls explain how it work properly
thanks
Kirtan PatelPosted Aug 6, 2009, 4:06 AM
you can Show record Like
1 to 20 of 51
20 to 40 of 51
40 to 51 of 51
follow the below Code
To Show That Page String in Footer Do This
Happy Coding :)
Danatas GerviPosted Aug 6, 2009, 3:55 AM