Solved

c# Detecting RowState Edit on Details View

Posted on 2009-05-07
3
779 Views
Last Modified: 2012-05-06
I have the code below that is hiding empty rows in a details view.
Now when I click Edit some of the rows are missing.

This I think is due to the output of the RowState being as below.
-Edit-
-Alternate, Edit-
-Edit-
-Alternate, Edit-
-Edit-
-Alternate, Edit-
-Edit-
-Alternate, Edit-
-Edit-
-Alternate, Edit-

So although I'm picking up the Edit state, how can I also detect for Alternate, Edit state ?
protected void HideEmptyDeliveryDetailRows(object sender, EventArgs e)
    {
        String data;
        int RowCount = DeliveryDetailsDetailsView.Rows.Count;
 
        foreach (DetailsViewRow r in DeliveryDetailsDetailsView.Rows)
        {
            Response.Write("-" + r.RowState.ToString() + "-<br>");
 
            if (r.RowState != DataControlRowState.Edit)
            {
                if (r.Cells.Count > 1)
                {
                    data = r.Cells[1].Text;
                }
                else
                {
                    data = r.Cells[0].Text;
                }
 
                if (r.RowIndex == RowCount - 1)    // If its the last one then leave as is due to edit button.
                    data = "123";
 
                data = data.Replace("&nbsp;", "").Trim();
                if (data == null || data == "")
                {
                    r.Visible = false;
                }
            }
        }
    }

Open in new window

0
Comment
Question by:andrewmilner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 24323890
Try removing the Trim from this sentence

data = data.Replace("&nbsp;", "").Trim();


I'm not able to understand why do u need this line?
0
 

Author Comment

by:andrewmilner
ID: 24329401
If I remove the &nbsp line then during the normal view before the edit has been clicked then it doesnt hide the empty rows.
I can't explain the full reason its there as I got the code from a different post.
0
 

Accepted Solution

by:
andrewmilner earned 0 total points
ID: 24335963
Solve it now.

Changed the If to...
r.RowState != DataControlRowState.Edit && r.RowState.ToString() != "Edit" && r.RowState.ToString() != "Alternate, Edit"
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question