Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Can't get data in webdatagrid to refresh on sorting
posted

I have a datagride that is bound to a DataTable for it's source.  When clicking the column heading to sort the data I need to rebuild the DataTable and rebind that to the datagrid.  

The reason for this is that one of the columns in the DataTable is a ranking based on the value selected.  

COLUMN1     COLUMN2     RANKING

-------------------------------------

100             42              

271             72

67               92

My stored procedure will apply the ranking column if I pass in the column name.

COLUMN1     COLUMN2     RANKING

-------------------------------------

67              92                3           

100             42                2

271             72                1

To complicate things, the datagrid is on a webTab along with a MSChart and a dropdown to select the month of the data.  Ultimatly, what I woudl like to have happen is

1) user selects the Month from the drop down and the correct default data set loads (working now)

2) user selects a column and the dataset reloads, showing the new ranking, and the chart refreshes.  All still on the selected month. (not working)

Here is some code:

protected void ddSelectMonth_SelectedIndexChanged(object sender, EventArgs e)

    {

        loadContent("", ddSelectMonth.SelectedValue);

    }

private void loadContent(string sort_order, string selected_month)

    {

        using (SqlConnection conn = new SqlConnection(dsn_dashboard))

        {

            DataSet ds = new DataSet();

            string sSQL = @"exec getReportPowerUtilizationRanking '" + sort_order + "'," + selected_month;

            lblTest.Text = sSQL;

            using (SqlCommand cmd = new SqlCommand(sSQL, conn))

            {

                conn.Open();

                SqlDataReader dr = cmd.ExecuteReader();

                ds.Load(dr, LoadOption.OverwriteChanges, new string[] { "Global Data", "Region Data", "Center Data" });

                conn.Close();

            }

            chart_centers.DataSource = ds.Tables[2];

            chart_centers.DataBind();

            dataGrid_centers.DataSource = ds.Tables[2];

            dataGrid_centers.DataBind();

        }

    }

protected void dataGrid_centers_ColumnSorted(object sender, Infragistics.Web.UI.GridControls.SortingEventArgs e)

    {

            string str = dataGrid_centers.Columns[e.Column.Index].Key;

            loadContent(str, ddSelectMonth.SelectedValue);

    }

Parents Reply Children
No Data