开发者

GridView Find a Row in Edit Mode

开发者 https://www.devze.com 2023-02-14 06:22 出处:网络
I posted similar question before, but I still have some problem with it. I use asp.net 4 and c#. I have a GridView, I have some logic in A) to change the value for every Label present in the GridView

I posted similar question before, but I still have some problem with it. I use asp.net 4 and c#.

I have a GridView, I have some logic in A) to change the value for every Label present in the GridView (this part of code is working). PS: I use even 开发者_如何学Python_RowDataBound (Let me know if it is correct).

I need also apply some logic ONLY for a single ROW when goes in EDIT MODE.

Here my code. It works just if the ROW in EDIT MODE is the first one in the GridView. If i put in EDIT MODE for example the 3third row does not work.

Any idea?? Thanks

    protected void uxManageSponsoredContentsDisplayer_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            switch (e.Row.RowType)
            {
                case DataControlRowType.DataRow:
                // A) - Some code here

                if (e.Row.RowState == DataControlRowState.Edit)
                {
                // Here some logic to apply only to ONE ROW!

                }
                break;
             }         
        }


I have the same problem. What happen is that the second, fourth, and so on, rows are on an Alternate state so when you click edit they change to Alternate|Edit state. You have to check if the row has an alternate|edit state too. Here's something that may help you. For me is working just fine.

protected void uxManageSponsoredContentsDisplayer_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        switch (e.Row.RowType)
        {
            case DataControlRowType.DataRow:
            // A) - Some code here

            if (e.Row.RowState ==(DataControlRowState.Alternate|DataControlRowState.AlternateEdit) || e.Row.RowState == DataControlRowState.Edit )
            {
            // Here some logic to apply only to ONE ROW!

            }
            break;
         }         
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消