Solved

c# Detecting RowState Edit on Details View

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

10 Experts available now in Live!

Get 1:1 Help Now