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

    In gridview it never show the first data in asp.net

    in my gridview if i change any data my first row is not shown

    my code

    private void BindListView()
    {
    string constr = ConfigurationManager.AppSettings["s"].ToString();
    using (SqlConnection con = new SqlConnection(constr))
    {
    using (SqlCommand cmd = new SqlCommand())
    {
    using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
    {
    cmd.CommandText = "SELECT distinct sectionname,lotno,Productname,mrp,supplierename,sizee,qty from purchasedummy where lotno='" + txtBarcode.Text + "'";
    cmd.Connection = con;
    DataTable dt = new DataTable();
    sda.Fill(dt);
    DataTable products = new DataTable();
    if (ViewState["Products"] == null)
    {
    products.Merge(dt, true);
    }
    else
    {
    products = (DataTable)ViewState["Products"];
    products.Merge(dt, true);
    }
    ViewState["Products"] = products;
    ddsales.DataSource = products;
    ddsales.DataBind();
    if (products.Rows.Count == 0)
    {
    Response.Write("<script>alert('Please Enter Bill Amount !')</script>");
    }
    else
    {
    Calc();
    }
    }
    }
    }
    txtBarcode.Text = "";
    }
  • #762478
    in this image c my first row is not show

    gridviewnonshowdata.bmp

    Delete Attachment

  • #762480

    Hi

    In your code ddsales_RowDataBound I have some changes now fixed that issue try this code.

    Comment this line in your ddsales_RowDataBound method. Now fixed this issue


    //GridViewRow row = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Insert);
    //TableCell th = new TableHeaderCell();
    ////th.ForeColor = Color.White;
    ////th.BackColor = Color.SteelBlue;
    //th.Text = "Bramandam Family Shop<br/> DEvakottai";
    //th.ColumnSpan = ddsales.Columns.Count;
    //row.Cells.Add(th);
    //ddsales.Controls[0].Controls.AddAt(0, row);


    I have attached Snap shot


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

    Delete Attachment


Sign In to post your comments