Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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:
C#
public DataSet UserGridDetail(BEL.BEL objUserDetails)
        {
            DAL.DAL UDGrid = new DAL.DAL();
            DataSet ds = UDGrid.UserDetailGrid(objUserDetails);
            return ds;
        }
InCodeBehind:
C#
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();
        }
Posted
Updated 23-Jul-12 23:20pm
v2
Comments
_Amy 24-Jul-12 3:17am    
What have you tried so far?
charan anasam 24-Jul-12 4:13am    
before beginning my question i told that i'm new to this,if u know any solution guiding is better rather than questioning again?
Rockstar_ 24-Jul-12 3:19am    
Check the query weather it is returning the rows or not. i mean the query is producing the result or not.
Rockstar_ 24-Jul-12 3:20am    
Can u show ur Code.......

1 solution

change
C#
Grd_Details.DataSource = ds;

to
C#
Grd_Details.DataSource = ds.Tables[0];
 
Share this answer
 
Comments
Vani Kulkarni 24-Jul-12 5:37am    
Will it really matter if the result set contains only one table? I think giving Grd_Details.DataSource = ds should work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900