You must Sign In to post a response.
  • Category: .NET

    How to call label values in bottom of gridview

    I am creating windows application using c# 2010 – here I am using datagridview for billing purpose,We are entered many more rows is datagridview but not entered in fixed, it means first time billing entered 10 rows, second time billing entered 40 rows, here I want how to call label values in bottom of datagridview. Give me any one some ideas.
  • #768378
    Try this:

    foreach (DataGridViewRow r in dgvMain.Rows)
    DataGridViewLinkCell lc = new DataGridViewLinkCell();
    lc.Value = r.Cells[0].Value;

  • #768386
    You can use this example of code snippet add checkboxes in and get gridview selected rows data on button click in
    public partial class BindGridviewwithCheckboxes : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
    protected void BindGridviewData()
    DataTable dt = new DataTable();
    dt.Columns.Add("UserId", typeof(Int32));
    dt.Columns.Add("UserName", typeof(string));
    dt.Columns.Add("Education", typeof(string));
    dt.Rows.Add(1, "Suresh Dasari", "B.Tech");

  • #768389
    label values means ? do you want to show the sum of all rows or any specific columns ? what you want to show in footer
    here is a small code snippet to show values in gridview footer

    protected void GridDataBound(object sender, EventArgs e)
    GridView grid = (GridView)sender;
    DataTable source = (DataTable)grid.DataSource;
    decimal totalSum = source.AsEnumerable().Sum(r => r.Field<decimal>("Total"));
    labelOverall.Text = totalSum.ToString();

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • Sign In to post your comments