hello friends
I am trying to convert a vb.net datagridview code into asp.net. I want to display last three rows of table column from database table in gridview column1.

         Dim dt As New DataTable

        ' Create columns
        dt.Columns.Add("column1", Type.GetType("System.String"))
        dt.Columns.Add("column2", Type.GetType("System.String"))
        dt.Columns.Add("column3", Type.GetType("System.String"))
        dt.Columns("column3").Expression = "[column1]+[column2]"
        dt.Rows.Add("", "")
        dt.Rows.Add("", "")
        dt.Rows.Add("", "")
        dt.Rows.Add("", "")

        Me.GridView1.DataSource = dt

        GridView1.DataBind()




    I know how to display table data in gridview using the code below



   Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\dtb.accdb")
        Dim Query2 As String = "select * from table1"
        Dim Da As OleDbDataAdapter, Ds As New DataSet, Dtb As New System.Data.DataTable
        con.Open()
        Da = New OleDbDataAdapter(Query2, con)
        Da.Fill(Ds)
        con.Close()
        Dtb = Ds.Tables(0)
        GridView1.DataSource = Dtb
        GridView1.DataBind()

the gridview shows in web form but I cannot make any input in gridview cell,also how to bind last three rows in column1. can someone please help me with this
thanks

Hi,

depending on how youb process the rows. Assuming you loop them all through
when update button is clicked. You could just iterate

For Each row As GridViewRow in GridView1.Rows

Dim cbDelete As CheckBox = DirectCast(row.FindControl("CheckBox1"),
CheckBox)

' Accessing text in first Cell
Dim strText As String = row.Cells(0).Text
'...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.