c# - 在 gridview 中不显示第一行

标签 c# asp.net

在 gridview 中,我尝试显示数据库中的数据,但它忽略了表格中的第一行并占用了其余行..,请建议我该怎么做.. 下面是我的代码。

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();
    }

最佳答案

删除 dr.Read(); 行。

您正在超越已经领先一位的读者。

关于c# - 在 gridview 中不显示第一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32776842/

相关文章:

c# - 以编程方式打开/关闭 WiFi 热点

asp.net - Web应用程序被锁定并且CPU使用率达到100%

c# - 无法将 List<> 对象序列化/反序列化为 JSON

asp.net - CSS 在本地工作但不在开发服务器上

c# - 在按钮 WPF 中添加带有 fontawesome 的文本

c# - 集合更改时未更新 GroupStyle header 中的绑定(bind)

c# - 如何使用 LINQ to XML 获取属性值?

c# - Winform自动省略号宽度

c# - 单击在 asp :Repeater 中呈现的 ascx 控件中的按钮时丢失值

javascript - 如何使用 MS Word 中显示的三个按钮 'Yes' 'No' 和 'Cancel' 显示确认警报