This is a migrated thread and some comments may be shown as answers.

Databinding with DataSet

1 Answer 88 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Saikat
Top achievements
Rank 1
Saikat asked on 10 Oct 2011, 09:33 AM
I am using the Radcontrol Windows Grid to bind data returned by a 'Select' query.
The piece of code is something like this:

            SqlDataReader dr = null;
            SqlConnection conn = null;
            try
            {
                this.radGridView1.MasterGridViewTemplate.AutoGenerateColumns = true;
                this.radGridView1.GridElement.BeginUpdate();
                DataSet ds = new System.Data.DataSet();
                string connectionString = ConfigurationManager.AppSettings["Conn"];
                conn = new SqlConnection(connectionString);
                SqlCommand cmd = new SqlCommand("SELECT * FROM Payment");
                cmd.Connection = conn;
                conn.Open();
               SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                da.Fill(ds);
                radGridView1.DataSource = ds.Tables[0].DefaultView;
             }
            catch (Exception ex)
            {
            }
            finally
            {
                conn.Close();
                dr.Dispose();
            }
Although the dataset is returning rows as a resultset, but when the grid loads, it displayes nothing. Is there anything I am missing.
I want to Auto generate the columns.
Thanks,
Saikat

1 Answer, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 10 Oct 2011, 11:40 AM
Hello,

This line here:
this.radGridView1.GridElement.BeginUpdate();
has no corresponding EndUpdate,

Please use the newer mechanism provided by telerik the using (radGridView1.DeferRefresh() { ... } ). to avoid this kind of issues in the future.

I believe it will work like this.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga

Telerik WinForms MVP

Tags
GridView
Asked by
Saikat
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Share this question
or