Can I add a text value to a gridview cell "manually" vs via dataset?

I've got a working ASP app with a gridview populated via a SQL select string.
I'd like to add a column at the end of the gridview, and populate it in a For loop, where I'm doing some other checks when the gridview refreshes..

Something like:
                    GridView1.Rows(i).Cells("MYNEWCOLUMNNAME").Text = "hi"

Open in new window

I tried adding a new column in the gui "SITE", as a BoundField, but I'm thinking this isn't going to work quite that easily..

Thoughts?
Richard GouetteIT ManagerAsked:
Who is Participating?
 
Dirk StraussSenior Full Stack DeveloperCommented:
If you have an ASP.NET app, you would need to add your column to the grid and then perform your logic in the ItemDataBound event of the grid to do the required checks and insert the value into the column you added.

I'm not sure if this is what you need. Do you want to add the extra column after the initial grid bind? The ItemDataBound event fires as each row in your grid is populated.
0
 
Richard GouetteIT ManagerAuthor Commented:
the 'manual' data would be bound after the initial gridview data is bound.
In my page load, I have  a for loop that's doing some manipulation of cells, and I was hoping I could insert
values into my new column within that loop..
Not sure if that makes sense
I noobishly thought that I could insert logic such as:
GridView1.Rows(i).Cells("CELLNAME").Text = "hi"

Open in new window

0
 
Richard GouetteIT ManagerAuthor Commented:
I adding this under the page load event:
        Dim ColumnName As New BoundColumn()
        ColumnName.DataField = "SITE"
        ColumnName.HeaderText = "SITE"

Open in new window


It adds a new column, but I cannot manage to poke any values into any new cells..?
I do not see 'ItemDataBound' as an event of my gridview: maybe I'm looking in the wrong place..?
0
 
Richard GouetteIT ManagerAuthor Commented:
going to repost and hopefully,. make more sense of what I've got , and am doing
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.