0

Here is the deal. I have a Master-Detail Grid scenario. The Master GridView is loaded when the page is loaded. I am using a DataView of same DataTable which loads the Master to load the Detail GridView, by filtering what I need to show in the DetailGridView. Everything works fine when I view the first row of the MasterGridView. When I try to view the second row, I the the error "column[number] not found. I also notice that the "table" variable is nothing.

public partial class Gridview_Template : System.Web.UI.Page
{
    DataTable table = new DataTable();

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlDataReader reader = DBSqlHelperFactory.ExecuteReader(
            myconnection,
            "crm_getcustomersummary",
            new SqlParameter("@customerid", "99999")
        );
        table.Load(reader);
        MasterGridView.DataSource = table;
        MasterGridView.DataBind();
    }

    protected void detailGrid_DataSelect(object sender, EventArgs e)
    {
        string searchValue ="number="  + values.ToString();

        DataView dv = new DataView(
            table, searchValue, "number", DataViewRowState.OriginalRows
        );
        DetailGridView.DataSource = dv;

        // ...
    }
}

Am I to put the "table" variable in a session state so it exists across call?

1 Answer 1

1

If you just want to persist the table between postback, then you may want to take a look at ViewState. Session is used more for persisting information across different pages.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.