troubleshooting Question multiple emptyrows and looping through

Avatar of louise_8
louise_8 asked on
2 Comments1 Solution193 ViewsLast Modified:

I want to allow users to enter 3 new rows into a gridview if its empty
which is the best way to display them (can I use the same control names in each emptyrow)

and how do I loop through in the code behind?

Using the code below I'm only getting the first row:

  int iCount = GridView1.Rows.Count; // this only returns 0
        if (CommandName == "InsertNewRow")
            for (int iCounter = 0; iCounter <= iCount; iCounter++)
                GridViewRow emptyRow = GridView1.Controls[iCounter].Controls[iCounter] as GridViewRow;
 Discount discount = new Discount();

                discount.Description = convert.ToString(((TextBox)emptyRow.FindControl("NewRowDescription")).Text);
                discount.MinimumUnits = int.Parse(((TextBox)emptyRow.FindControl("NewRowMinUnits")).Text);
   ... etc
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros