Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c# Detecting RowState Edit on Details View

Posted on 2009-05-07
3
Medium Priority
?
788 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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