Solved

c# Detecting RowState Edit on Details View

Posted on 2009-05-07
3
766 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
Comment Utility
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
Comment Utility
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
Comment Utility
Solve it now.

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

12 Experts available now in Live!

Get 1:1 Help Now