GID视图正在显示,但未从数据库获取记录 [英] Gid view is displaying but not getting records from database

查看:123
本文介绍了GID视图正在显示,但未从数据库获取记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我对.net中的层体系结构模型来说还很陌生,我的问题是
单击提交"按钮后在文本框中输入用户名时,单击提交"按钮后,我必须显示网格视图,而不是显示数据库中的值.

这是我的代码:
DAL:

hi to all,
i''m pretty new to tier architecture model in .net and my problem is
when a username is given in the textbox after clicking the submit button i have to display the grid view when i''m clicking the submit button the grid is displaying but not the values from the database.

here is my code:
DAL:

public DataSet UserDetailGrid(BEL.BEL objBELUserDetailGrid)
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("Usp_GridUserDetails", con);
            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                DataSet ds = new DataSet();
                cmd.Parameters.AddWithValue("@UserName", objBELUserDetailGrid.UserNam);
                 SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(ds);
                con.Close();
                return ds;
            }
            catch (Exception ex)
            {
                throw ex;
                return null;
            }
            finally
            {
                cmd.Dispose();
                con.Close();
                con.Dispose();
            }
        }

BLL:

BLL:

public DataSet UserGridDetail(BEL.BEL objUserDetails)
        {
            DAL.DAL UDGrid = new DAL.DAL();
            DataSet ds = UDGrid.UserDetailGrid(objUserDetails);
            return ds;
        }

InCodeBehind:

InCodeBehind:

protected void BtnDetails_Submit_Click(object sender, EventArgs e)
        {
            Grd_Details.Visible = true;
            BL.BLL objgridviewdetail = new BL.BLL();
            BEL.BEL objGUDBEL = new BEL.BEL();
            objGUDBEL.UserNam = TxtDetails_UserName.Text;

            DataSet ds = objgridviewdetail.UserGridDetail(objGUDBEL);
            Grd_Details.DataSource = ds;
            Grd_Details.DataBind();
        }

推荐答案

change
Grd_Details.DataSource = ds;




to

Grd_Details.DataSource = ds.Tables[0];


这篇关于GID视图正在显示,但未从数据库获取记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆