如何从数据网格中删除行(如果它们存在于另一个gridview中) [英] How to remove rows from a datagrid if they exist in another gridview

查看:117
本文介绍了如何从数据网格中删除行(如果它们存在于另一个gridview中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我的网页上有2个GridView,它们都通过SqlDataSource Connections连接到不同的表.

第一个SqlDataSource和GridView,获取调用列表并返回调用引用和调用状态.

第二个SqlDataSource和GridView获取链接案例列表并显示,该调用的Call Ref及其链接到的调用(每个链接调用2个条目).

我想做的是过滤掉链接的调用,使它们不显示在GridView 1中,但不确定如何遍历GridView2中的值?

抱歉,如果不清楚,但是如果您需要,我会尽力为您提供详细信息.

一如既往,在此先感谢.

Pete

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

推荐答案

创建3个DataTable的
DT1用于网格1,DT2用于网格2,DT3作为组合解决方案.

在DT satasource中,您可以绑定到gridview(s)

在DT3上进行过滤.

如果您已经显示了详细信息,则想遍历显示的数据-不可避免地会遇到性能问题.并且您的视图状态不成比例.

离开表格时进行处置...
GC中介3很好.



//创建数据表
DataTable dt = new DataTable();

//在其中添加一些列.
dt.Columns.Add(new DataColumn("Item#",typeof(int)));
dt.Columns.Add(new DataColumn(合同编号",typeof(字符串)));
dt.Columns.Add(new DataColumn("Customer Name",typeof(string)));

//创建记录
DataRow dr = dt.NewRow();
dr ["Item#"] = 1;//i;
dr [客户名称"] = Textbox1.Text;//xmn2 [1] .InnerText; //来自屏幕上文本框的值
dr [合同编号"] = Textbox1.Text;//xmn4 [1] .InnerText; //来自屏幕上文本框的值
dt.Rows.Add(dr);

//将GridView绑定到数据表中的数据以进行显示.
this.GridView1.Visible = true;
GridView1.DataSource = dt;
GridView1.DataBind();
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();


这篇关于如何从数据网格中删除行(如果它们存在于另一个gridview中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆