Bind 2 WebGrids to Dataset

6 replies. Last post: September 15, 2009 4:19 PM by Michael Giger
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

Hi

I have a Dataset with 2 DataTables (Table A and Table B).

On the Page they are 2 WebGrids (WebGrid A and WebGrid B)

Now, I want bind WebGrid A to Table A and WebGrid B to Table B.

How can I do this?

 

I have written the following Code:

On Page_Load I fill the Dataset with 2 Tables

        protected void Page_Load(object sender, EventArgs e)
        {
            ds = GetData();
        }


GetData() has 2 Select-Statement:

SELECT ID AS IDTableA FROM TableA

SELECT ID AS IDTableB FROM TableB

 

On InitializeDatasSource (similar for Table B):

        protected void WebGridA_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            e.DataSource = ds.Tables["TableA"];
        }


On PrepareDataBinding (similar for Table B):

        protected void WebGridA_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            if (!Page.IsPostBack)
            {
                WebGridA.RetrieveStructure();
            }

        }

If I run the project, I get an exception "Can't find DataColumn with name 'IDTableA' in the specified datasource"

 

I have also tried to set DataMember = TableA/TableB in PrepareDataBinding-Event. Then both WebGrid have the same Data!

How can I bind 2 WebGrids to Dataset?

 

Thanks for help.

Michael

All times are GMT -5. The time now is 9:19 PM.
Previous Next