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?
SqlConnection(ConfigurationSettings.AppSettings("KormaSQLConnectionString"))
            Conn.Open()

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

            DataGrid.DataSource = SQLData
            DataGrid.DataBind()


            SQLData.Close()
            Conn.Close()

Open in new window

MrDavidThornAsked:
Who is Participating?
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.

khan_webguruCommented:
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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
0
CodeCruiserCommented:
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.
0
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 _
               SqlConnection(ConfigurationSettings.AppSettings("String"))
            Conn.Open()

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

            MasterDataGrid.DataSource = SQLData
            MasterDataGrid.DataBind()

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

            MasterDataGrid.Columns.AddAt(5, NewColoumn)

Open in new window

0

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.

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.