Advertisement

11.29.2007 at 10:20AM PST, ID: 22991288
[x]
Attachment Details

Problem with Adding a new row to an existing datagrid

Asked by cesemj in .NET Framework 2.0, Visual Studio .NET 2005

Tags: row, add, new, adding, datagrid

Hello,

The existing data table binded to a grid works When I enter the number of line items I need and click on a button that say make grid.  The problem is when click on Add Rows the extra row does not appear.  I think I am having a problem with the databind, because if I use, gvParts.DataBind(), the existing datagrid goes away.


Thank you in advance,

Existing Code used to create the data table to add records (WORKS)
**********************************************************
    Protected Sub btnMkGrid_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnMkGrid.Click
        Dim dt As New Data.DataTable
        'Dim tblReceiving As Table
        dt.Columns.Add(New Data.DataColumn("LineNO"))
        For i As Integer = 1 To tbItems.Text
            Dim dr As Data.DataRow
            dr = dt.NewRow
            dr("LineNO") = i
            dt.Rows.Add(dr)
        Next
        'Bind the DataTable to the DataGrid
        gvParts.DataSource = dt
        gvParts.DataBind()
 
    End Sub

****************************************************
Does Not Work
Protected Sub AddRow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddRow.Click

        'Add the number of rows specified by "RowCount" to gvParts
        If (IsNumeric(RowCount.Text)) Then
            Dim i As Integer
            For i = 1 To CInt(RowCount.Text)

                'Adding a blank record to the dataset.
                Dim dt As New Data.DataTable
                dt.Columns.Add(New Data.DataColumn("LineNO"))
                Dim dr As Data.DataRow
                dr = dt.NewRow
                dr("LineNO") = i
                dt.Rows.Add(dr)

            Next
        End If
        'Rebind the grid to show the newly added row(s).
        'gvParts.DataBind()
        'DataBind()

    End Sub
Start Free Trial
[+][-]11.29.2007 at 01:05PM PST, ID: 20377327

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.01.2007 at 06:32AM PST, ID: 20388092

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.01.2007 at 02:02PM PST, ID: 20389441

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 05:40AM PST, ID: 20402604

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 06:36AM PST, ID: 20403014

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 11:20AM PST, ID: 20405495

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 01:34PM PST, ID: 20406774

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.04.2007 at 02:47PM PST, ID: 20407375

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.05.2007 at 10:33PM PST, ID: 20417734

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.06.2007 at 11:45AM PST, ID: 20422511

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.0, Visual Studio .NET 2005
Tags: row, add, new, adding, datagrid
Sign Up Now!
Solution Provided By: surajguptha
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628