Button控制GridView

pingxuan1987 2011-01-19 05:20:17
请教各位大侠,我想通过一个Button点击事件来隐藏GridView中的某一列,这样可以实现吗?注:Button不是嵌在GridView中,而是独立在外的一般Button。
...全文
124 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
pingxuan1987 2011-01-20
  • 打赏
  • 举报
回复
问题在10帮助下解决了,谢谢大家
wuyq11 2011-01-19
  • 打赏
  • 举报
回复
this.GridView1.Columns[0].Visible = false;
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 1; i <= 7; i++)
{
this.GridView1.Rows[i].Columns["列名"].Visible = false;
}
}

pingxuan1987 2011-01-19
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 rwm5366745 的回复:]
Button 点击事件

GridView1.Cells[第几列].Visable=false;
[/Quote]

还是不行,下面是我的代码,新手,求救

protected void Button1_Click(object sender, EventArgs e)
{
gvView.Cells[5].Visable = false;
BindData();
}

错误 22 “System.Web.UI.WebControls.GridView”不包含“Cells”的定义,并且找不到可接受类型为“System.Web.UI.WebControls.GridView”的第一个参数的扩展方法“Cells”(是否缺少 using 指令或程序集引用?)
qiqittjj 2011-01-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
找到那个列,设置其visible属性
[/Quote]

这个比较简单!
jesson_bai 2011-01-19
  • 打赏
  • 举报
回复
string SqlDelStr = "delete from useradmin where userid=" + this.dataGridView1.SelectedRows[0].Cells[1].Value.ToString();

SelectedRows表示的是在DataGridView中所选择的行,其中Count属性是表示的选择的行数
CurrentRow表示的就是所选择的当前行,只有一行
dataGridView1.Rows[dataGridView1.CurrentRow.Index ].Cells["id"].Value.ToString() ;
rwm5366745 2011-01-19
  • 打赏
  • 举报
回复
Button 点击事件

GridView1.Cells[第几列].Visable=false;

秦皇 2011-01-19
  • 打赏
  • 举报
回复
display="none"
孟子E章 2011-01-19
  • 打赏
  • 举报
回复
也可以采用js进行处理。
tabel1.rows[i].cells[j].style.display="none"
garfieldzf 2011-01-19
  • 打赏
  • 举报
回复
Winform or Webform
孟子E章 2011-01-19
  • 打赏
  • 举报
回复
Button_OnClick:

遍历 GridView.Rows,设置 GridView.Rows[i].Cells[j].Visible=false;
bdmh 2011-01-19
  • 打赏
  • 举报
回复
找到那个列,设置其visible属性

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧