Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert Extra Row into Gridview

Posted on 2007-11-28
6
Medium Priority
?
2,996 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

670 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