使gridview中的一个单元格不可见? [英] Make one cell in gridview invisible?

查看:63
本文介绍了使gridview中的一个单元格不可见?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一个显示数据集和一些按钮的gridview。当这个数据集的某个

单元格为空时,我希望该行中的一个按钮可以看到
,否则该行中不会显示任何按钮。


我正在努力让这一整天工作,但它不会起作用。


我在rowCreated事件中试过这个。我能够找到正确的行

和此行中的单元格(作为数据行),但现在正确的gridview

行单元格应该可见。


这就是我现在所拥有的(C#):


protected void supplierFilesGrid_RowCreated(object sender,

GridViewRowEventArgs e )如果(e.Row.RowType == DataControlRowType.DataRow)

{

DataRowView drView =(DataRowView)e.Row.DataItem;

DataRow drRow = drView.Row;


if(drRow [2] .ToString()==" ; NEW")

{

int i = e.Row.RowIndex; //

这很好用,之后我收到一个错误:

//grid.Rows [i] .Cells [1] .Visible = false; //

argumentOutOfRangeException ...

(发送者为GridView).Rows [i] .Cells [1] .Visible =

false;

}

}

}


有没有人建议如何使这项工作?


提前致谢!


问候,

Jo

Hi all,

I have a gridview displaying a dataset and some buttons. When a certain
cell of this datasetrow is empty, I want a button in that row to be
visible, otherwise no button should be shown in that row.

I''m trying to make this work all day, but it''s not going to work.

I tried this in the rowCreated event. I am able to find the right row
and cell in this row (as a datarow), but now the right gridview
row-cell should be made visible.

This is what I have right now (C#):

protected void supplierFilesGrid_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drView = (DataRowView)e.Row.DataItem;
DataRow drRow = drView.Row;

if (drRow[2].ToString() == "NEW")
{
int i = e.Row.RowIndex; //
this works fine, after this I get an error:
//grid.Rows[i].Cells[1].Visible = false; //
argumentOutOfRangeException...
(sender as GridView).Rows[i].Cells[1].Visible =
false;
}
}
}

Has anyone a suggestion how to make this work?

Thanks in advance!

Regards,
Jo

推荐答案

我相信你想要grid.ItemDataBound事件

I believe you want the grid.ItemDataBound event


你好,

也许我这样做,但在这次活动中该怎么做?


问候,

Jo

Hi,
Maybe I do, but what should I do within this event?

Regards,
Jo




以下是我在本次活动中为您提供的代码片段。


e.Item.Cells.Item( 4).ToolTip = e.Item.Cells.Item(5).Text


Here is a snippet of code I have in this event to get you started.

e.Item.Cells.Item(4).ToolTip = e.Item.Cells.Item(5).Text


这篇关于使gridview中的一个单元格不可见?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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