Vinay
Vinay

Reputation: 59

In gridview is not displaying the first row

In gridview that am try to displaying the data in the database but it is ignoring the first row from the tabel & taking the rest of row.., plz suggest me what to do.. below is my code.

protected void Page_Load(object sender, EventArgs e)
    {
        DBLibrary obj = new DBLibrary();
        String Parent = (string)Session["parentName"];
        String ss = "Select StudentId from Tbl_Parents where parentName='" + Parent + "'";
        SqlDataReader dr6 = obj.ExecuteReader(ss);
        dr6.Read();
        string id = dr6[0].ToString();
        string bind = "SELECT AnuFeeMaster.StudentId, Tbl_Student.SName, AnuFeeMaster.Month, AnuFeeMaster.Year, AnuFeeMaster.FeeAmount, " +
                    " AnuFeeMaster.PaidAmount FROM  AnuFeeMaster INNER JOIN Tbl_Student ON AnuFeeMaster.StudentId = Tbl_Student.StudentId where ( AnuFeeMaster.StudentId ='" + id + "')";//and (AnuFeeMaster.ChkDate='" + date.ToString() + "') ";
        SqlDataReader dr = obj.ExecuteReader(bind);
        dr.Read();
        gv1.DataSource = dr;
        gv1.DataBind();
    }

Upvotes: 2

Views: 922

Answers (1)

Mihai Caracostea
Mihai Caracostea

Reputation: 8466

Remove the dr.Read(); line.

You are passing the reader already advanced with one position.

Upvotes: 1

Related Questions