显示和隐藏网格视图选定的行特定单元格

发布于 2024-11-06 13:05:03 字数 1372 浏览 3 评论 0原文

目前我正在做一个项目。

网格中共有 5 列,其中 2 列可见 false。

name     email_id_X         email_id                 mobile_no_X   mobile_no   SELECT
-------------------------------------------------- ---------------------------------
Mahesh  maXXXXXXahoo.co.in  [email protected] 98XXXXXX96    986769696   SELECT
Kiran   kiXXXXXX.in         [email protected]        93XXXXXX333   9333333333  SELECT 
Kiran   kiXXXXXX.in         [email protected]        93XXXXXX333   9333333333  SELECT 
Kiran   kiXXXXXX.in         [email protected]        93XXXXXX333   9333333333  SELECT 
Amit    AmXXXXXXin          [email protected]         93XXXXXX333   9333333333  SELECT 

所以请告诉我如何隐藏 email_id 和 mobile_no 列。 当用户单击选择时,他只能看到选定的行 email_id 和 mobile_no。

谢谢。

Currently I'm working on one project.

There are total 5 columns in grid in which 2 are visible false.

name     email_id_X         email_id                 mobile_no_X   mobile_no   SELECT
-------------------------------------------------- ---------------------------------
Mahesh  maXXXXXXahoo.co.in  [email protected] 98XXXXXX96    986769696   SELECT
Kiran   kiXXXXXX.in         [email protected]        93XXXXXX333   9333333333  SELECT 
Kiran   kiXXXXXX.in         [email protected]        93XXXXXX333   9333333333  SELECT 
Kiran   kiXXXXXX.in         [email protected]        93XXXXXX333   9333333333  SELECT 
Amit    AmXXXXXXin          [email protected]         93XXXXXX333   9333333333  SELECT 

So please tell me how to hide the column email_id and mobile_no.
and when user click on select that time he can only see the selected rows email_id and mobile_no.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鹿港小镇 2024-11-13 13:05:03

首先为这两列设置 visible=false
然后,要仅获取您选择的行,请更改 datasourceid 并在 gridview1_SelectedIndexchanged 事件中绑定数据。

首先,对数据源的查询类似于Select * from table1
当您第二次绑定时,当您单击选择时,您的查询应该类似于Select * from table1 where emailid=xyz

First set visible=false for those two columns.
Then to get only the row u have selected, change the datasourceid and bind the data in the gridview1_SelectedIndexchanged event.

First the query for datasource it would be like Select * from table1.
When you are binding for the second time, when you have clicked the select, then you're query should be like Select * from table1 where emailid=xyz.

森林迷了鹿 2024-11-13 13:05:03

您可以使用 RowCommand 事件来执行此操作。就像..

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Select")
    {
        GridView1.Columns[2].Visible = false;
        GridView1.Columns[4].Visible = false;
    }
}

编辑:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Select")
    {
        GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
        row.Cells[2].Visible = false;
        row.Cells[4].Visible = false;
    }
}

You can do this using the RowCommand event. like..

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Select")
    {
        GridView1.Columns[2].Visible = false;
        GridView1.Columns[4].Visible = false;
    }
}

Edit:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Select")
    {
        GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
        row.Cells[2].Visible = false;
        row.Cells[4].Visible = false;
    }
}
失与倦" 2024-11-13 13:05:03

要隐藏某些列,您可以在后面的代码中添加以下内容:

GridView1.Columns[2].Visible = false;
GridView1.Columns[3].Visible = false;

这将隐藏 GridView 的第 3 和第 4 列。

To hide certain columns you can have this in the code behind:

GridView1.Columns[2].Visible = false;
GridView1.Columns[3].Visible = false;

This will hide the 3rd and 4th columns of the GridView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文