asp, c#, gridview

Webboy2008
Webboy2008 used Ask the Experts™
on
Have the following codes from one of our .cs file in app_code
How to call the CertificateSummaryClient in aspx code behind?
We have GridView control in frontend aspx as empty container.

Thanks
 
public DataSet CertificateSummaryClient()
    {
        using (SqlConnection ConString = new SqlConnection(WebConfigurationManager.ConnectionStrings["SqlDbConnection"].ToString()))
        {
            SqlCommand CmdCertificateSummary = new SqlCommand("CertificateSummary", ConString);
            CmdCertificateSummary.CommandType = CommandType.StoredProcedure;
            CmdCertificateSummary.Parameters.Add("@MemberId", SqlDbType.Int).Value = mMemberId;
            ConString.Open();
            SqlDataAdapter Da = new SqlDataAdapter(CmdCertificateSummary);
            DataSet ds = new DataSet();
            Da.Fill(ds);
            return ds;
        }      
    }
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Miguel OzSenior Software Engineer
Top Expert 2009

Commented:
Depending on how your gridview interacts with your page, one alternative is dynamic binding. check:
http://stackoverflow.com/questions/1659504/dynamic-databinding-to-gridview

In your case, add this code to page load event::
YourAppClass obj = new YourAppClass();
DataSet ds = obj.CertificateSummaryClient();
GridView1.DataSource = ds;
GridView1.DataBind();

Author

Commented:
Great. I will try. But how to set up column showing up....? I want to code in code behind instead of the aspx.
Senior Software Engineer
Top Expert 2009
Commented:
Regarding your further query. Check:
http://ramanisandeep.net/2009/04/07/how-to-hide-gridview-column-programmatically/
Basically add the code in the link after databind call.

Note: Another alternative, use the row data bound event: (GridView_RowDataBound)
http://stackoverflow.com/questions/3819247/gridview-hide-column-by-code

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial