C# DataGrid in Web App

Discussion in 'Meet and Greet' started by C#newbie, Dec 6, 2011.

Thread Status:
Not open for further replies.
  1. C#newbie

    C#newbie New Member

    Joined:
    Dec 6, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Does anyone know the issue with this code. I am trying to to display a datagrid from a stored procedure on a button click in the WebApp using C#. I have used this code developing a form and it worked perfect but won't translate to the WebApp . My connections are are set up correctly.

    cs is my connection
    da is my DataAdapter
    ds is my Dataset
    MessageBox is declared in a previous class and works correctly.

    The stored procedure executes correctly because I have checked my tables in the database that update on the button click. I just want to display the results on my WebApp.

    Any suggestions?

    Code:
     
    protected void Button2_Click1(object sender, EventArgs e)
            {
                da.SelectCommand = new SqlCommand("execute spTEST", cs);
                
    
                cs.Open();
                da.Fill(ds);
                dg.DataSource = ds.Tables[0];
                   MessageBox("SUCCESS!");
                cs.Close();
               
            }
    
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice