根据C#Windows应用程序中的条件禁用datagrid的某些行 [英] Disable certain rows of datagrid according to condition in C# Windows application

查看:91
本文介绍了根据C#Windows应用程序中的条件禁用datagrid的某些行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在数据库中,我有多行用于外键,并且我还有一个整数列名称"Sink"
我必须保持启用状态,仅使接收器"值最大的那一行数据网格
表示该外键值.
我必须禁用其他行.
我该怎么办?
请尽快答复
在此先感谢

In database i have multiple rows for foreign key and also i have one integer column names "Sink"
i have to keep enable only those rows of datagrid whose "sink" value is maximum
for that foreign key value.
i have to disable other rows.
how can i do these?
Please reply as soon as possible
thanks in advance

推荐答案

在gridview_rowdatabound事件中尝试此操作.
< pre lang ="c#">
如果(e.Row.RowType == DataControlRowType.DataRow)
{
字符串strOperation =(((DataRowView)e.Row.DataItem)["Operation"].ToString();
//查找从网格中删除的行并计算总金额
如果(strOperation =="2")
{
e.Row.Visible = false;
}
}
</pre>
In gridview_rowdatabound event try this.. I am sure this will help you.

<pre lang="c#">
if (e.Row.RowType == DataControlRowType.DataRow)
{
string strOperation = ((DataRowView)e.Row.DataItem)["Operation"].ToString();
//Finding the rows which is deleted from the grid and calculating the total amounts
if (strOperation == "2")
{
e.Row.Visible = false;
}
}
</pre>


这篇关于根据C#Windows应用程序中的条件禁用datagrid的某些行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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