Solved

c# Detecting RowState Edit on Details View

Posted on 2009-05-07
3
770 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now