Add new coloumn to datagrid via code .net 1.1

Hi, I have a datagrid that is databinded with A SQL server connection, I want to add a last coloumn to the data grid with a button for each row that will then navigate to another page. Any ideas on how I can do this?

            Cmd = New SqlCommand("SELECT * from mytable;", Conn)
            SQLData = Cmd.ExecuteReader

            DataGrid.DataSource = SQLData


Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

MrDavidThornAuthor Commented:
would I need to add my data to a datatable before databinding? I cant find an example where the data is bound and then a coloumn is added
If you declare the grid by setting autogenerate columns to false and adding the bound columns, the grid will show the columns whether there is data or not.
MrDavidThornAuthor Commented:
sorry seem to be struggling with this one, Im using the SQL data reader and databinding on that not on each coloumn I want the new coloumn (would be contain a button that hyperlinks to another page) to be created on the page load, what I have so far (which I know is wrong and incomplete) is

Public Conn As SqlConnection
    Public Cmd As SqlCommand
    Protected WithEvents lblTitle As System.Web.UI.WebControls.Label
    Protected WithEvents lblRecordCount As System.Web.UI.WebControls.Label
    Protected WithEvents MasterDataGrid As System.Web.UI.WebControls.DataGrid
    Public SQLData As SqlDataReader

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   Dim NewColoumn As ButtonColumn
            Conn = New _

            Cmd = New SqlCommand("SELECT * from test;", Conn)
            SQLData = Cmd.ExecuteReader

            MasterDataGrid.DataSource = SQLData

            NewColoumn.HeaderText = "test"
            NewColoumn.CommandName = "link"
            NewColoumn.Text = "test"

            MasterDataGrid.Columns.AddAt(5, NewColoumn)

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.