You must Sign In to post a response.
  • Category: Visual Studio

    Vb.net Data GridView Adding New row

    Dear All,

    i have a module in VB.Net with GridView.
    i have 4 columns in that GridView. While i click 1st column in grid, it popup another window with multiple records, if i choose any one record, that selected records line will fetch in main window(4 columns) Grid.

    i need one extra row every time, after selected record will fetch in gridview.

    As i know, whenever we type in gridview column, it automatically create a new line.

    But i need new row, even if we didn't type..

    Regards,
    Ramkumar G.R
  • #757041
    hi
    try this code

    I have add datatable and Bind gridview in Pageload method after button click event i added one column rebind the gridview check and let me know if u need assist


    Dim dt As New DataTable
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If (IsPostBack = False) Then
    dt.Columns.Add("Name")
    dt.Columns.Add("EmpNo")
    Dim dr As DataRow
    dr = dt.NewRow()
    dr(0) = "AA"
    dr(1) = "100"
    dt.Rows.Add(dr)
    Session("dtrecords") = dt
    Grd1.DataSource = dt
    Grd1.DataBind()
    End If
    End Sub
    Protected Sub Bt1_Click(sender As Object, e As EventArgs) Handles Bt1.Click
    Dim dt1 As New DataTable
    dt1 = Session("dtrecords")
    dt1.Columns.Add("Amount")

    Dim dr As DataRow
    dr = dt1.NewRow()
    dr(0) = "AA1"
    dr(1) = "1001"
    dr(2) = "1500"
    dt1.Rows.Add(dr)
    Session("dtrecords") = dt1
    Grd1.DataSource = dt1
    Grd1.DataBind()

    End Sub

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


  • Sign In to post your comments