【问题标题】:How to hide rows while editing a specific row from the user in gridview如何在gridview中从用户编辑特定行时隐藏行
【发布时间】:2015-06-16 10:10:22
【问题描述】:

我有一个连接到 SQL Server Management Studio 的 Web 应用程序。 我有一个问题要完成我的申请。 在我的 gridview 中,用户可以编辑他们自己的预订,但是一旦我到达 gridview 的更新部分,它就会告诉我用户可以编辑其他预订,这里有一些图片可以告诉你这个的含义:

1) 这是我的 gridview 事件中的代码

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{

    foreach (GridViewRow row in GridView1.Rows)
    {
        if ((row.Cells[9].Text.Trim()).Equals(HttpContext.Current.User.Identity.Name) == false)
        {
            //row.BackColor = Color.Red;
            row.Cells[0].Controls.Clear();          
        }        
   }
}

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
    Label1.Text = "Changed";

    GridViewRow selectedRow = GridView1.Rows[e.NewEditIndex];

    foreach (GridViewRow row in GridView1.Rows)
    {
        int currentIndex = row.RowIndex;

        if (currentIndex != e.NewEditIndex)
        {
            row.Visible = false; 
        }
    }
}

}

2) 这是为了告诉你用户只能编辑他们自己的预订

那我该如何解决呢?

【问题讨论】:

  • 3) 这是为了在用户更新他的预订时向您展示,他将能够编辑其他预订。 store1.up-00.com/2015-04/142868080993.png
  • 请考虑在问题中粘贴您的代码 sn-ps 以加快响应速度。
  • 我明白了你的问题。您能否将您的整个代码粘贴到您的问题中?
  • 你能再检查一下我的问题吗..我已经在那里添加了我的代码

标签: sql asp.net events gridview edit


【解决方案1】:

我已经更新了 GridView 的 RowEditing 事件:

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
     GridView1.EditIndex = e.NewEditIndex;
     // Bind Grid Again Here
}

【讨论】:

  • 抱歉我的愚蠢问题,但是在这里再次放置绑定网格是什么意思?我不是真正了解绑定网格代码的专家
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-25
  • 2014-12-24
  • 1970-01-01
  • 2020-04-11
  • 2013-02-05
  • 2021-06-17
相关资源
最近更新 更多