Solved

Insert Extra Row into Gridview

Posted on 2007-11-28
6
2,992 Views
Last Modified: 2008-02-01
Hi All

I have a Gridview which is databound which by default has a column containing textboxes within it's ItemTemplate.

What I would like to do is add an extra row (which will include a textbox) at the top of my Gridview which will enable me to add a value and then automatically populate the remainder Gridview rows.

Could any point me in the right direction on how to achieve this?

Many thanks

Rit

0
Comment
Question by:rito1
[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
  • 3
  • 2
6 Comments
 
LVL 6

Expert Comment

by:Roopesh_7
ID: 20366243
Check this link that may help you

http://forums.asp.net/p/1086446/1618481.aspx
0
 
LVL 1

Author Comment

by:rito1
ID: 20366323
Thanks Roopesh_7, I think I see how to insert an extra row. But would you or anyone know how I could make each row within a column reflect the value within a textbox which..

What I am trying to acheive is an 'Apply to all' function as some of the values within my gridview would be the same for each row.

For your info, my Grdiview functions similar to a spreadsheet thanks to the following posting... http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22908492.html

Many thanks

Rit
0
 
LVL 37

Expert Comment

by:samtran0331
ID: 20366737
It would be very similar to the post you linked to:

   Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        For Each gvr As GridViewRow In gvPeople.Rows
            If gvr.RowType = DataControlRowType.DataRow Then
                CType(gvr.FindControl("tbFirstName"), TextBox).Text = "EveryoneIsNamedSam"
            End If

        Next
    End Sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:rito1
ID: 20372480
Oh yeah, I see what you mean. I will piece this all together today and come back to you on the outcome.

Thanks for you help!

Rit
0
 
LVL 1

Author Comment

by:rito1
ID: 20372656
Hi

Regarding adding a new row to my Gridview, I am already using the Header row for header information and what I need to be able to do is add another row after the header but before the databound rows.

I can't seem to locate a way to acheive this as yet.

Does anyone have any ideas that they would mind sharing?

Rit
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 20373082
>>what I need to be able to do is add another row after the header but before the databound rows.

I would do it by creating my own datatable with columns that match the database query you're returning, then add a blank row to the datatabe, *then*, loop through the database query and add the rows to my custom datatable
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp Google Map 2 92
Google Maps with Webforms 1 45
Multi-Column Repeater 3 39
bulk load multiple users for aspnetusers table 2 14
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 …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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