Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I have 2 GridViews on my webpage that are both connected to different tables via SqlDataSource Connections.

The first SqlDataSource and GridView, gets a list of calls and returns the Call Ref and Call Status.

The second SqlDataSource and GridView gets a list of linked cases and displays, the Call Ref of that call and the call it's linked to (so 2 entries per linked call).

What I'm trying to do is filter out the linked calls so that they don't show in GridView 1 but unsure how to loop through the values in GridView2?

Sorry if this isn't clear but I will try and give you as much detail as I can if you need it.

As ever, thanks in advance.

Pete
Posted
Comments
Arvind Wanjari 22-Nov-10 9:51am    
try to compare datasource before binding to gridview ...

1 solution

Create 3 DataTable's
DT1 for grid 1, DT2 for grid 2, the DT3 as a combined solution.

within the DT satasource you can bind to the gridview(s)

do the filtering on the DT3.

if you already display details then want to loop through the displayed data - you'll have performance issues inevitably. and your viewstate is going out of proportion.

Dispose as you leave the form ...
GC interation 3 is nice.



//Create DataTable
DataTable dt = new DataTable();

//Put some columns in it.
dt.Columns.Add(new DataColumn("Item #", typeof(int)));
dt.Columns.Add(new DataColumn("Contract Number", typeof(string)));
dt.Columns.Add(new DataColumn("Customer Name", typeof(string)));

// Create the record
DataRow dr = dt.NewRow();
dr["Item #"] = 1;// i;
dr["Customer Name"] = Textbox1.Text;//xmn2[1].InnerText; //value from textbox on screen
dr["Contract Number"] = Textbox1.Text;//xmn4[1].InnerText; //value from textbox on screen
dt.Rows.Add(dr);

//Bind the GridView to the data in the data table for display.
this.GridView1.Visible = true;
GridView1.DataSource = dt;
GridView1.DataBind();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900