[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

adding info to xml table using datagrid

Posted on 2008-02-04
18
Medium Priority
?
450 Views
Last Modified: 2011-10-19
Yes i have an xml table that loads into a datagrid actually urltrawebgrid from Infragistics, but the case is when i add another row I can add the information but how can i insert the info within my bounded xml table using vb.


Dim ds As DataSet = CreateDataSource()
        Dim row As DataRow
 
        For Each row In ds.Tables(0).Rows
            row("unit_price") = ""
            row("case_price") = ""
            row("SRP") = ""
        Next
 
        ds.WriteXml(_XmlPreview)
 
        'sTemp = 5
 
        With UltraWebGrid1
            '.EditItemIndex = -1
            .DataSource = CreateDataSource().Tables(0)
            .DataBind()
        End With

Open in new window

0
Comment
Question by:Seven price
  • 11
  • 7
18 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20823170
I don't understand.  You create 'ds' with a call to CreateDataSource, but then you bind the UltraWebGrid to a completely different data source, which also uses CreateDataSource.  Why aren't you using ds.Tables(0) instead?

Bob
0
 
LVL 9

Author Comment

by:Seven price
ID: 20823582
sorry yes I want to create lets say a dataset but I want to add to my xml table. if you like to see my xml table not a problem I create and update but when i add a new row i need the tags to be also created in the xml for the new row to be saved. below is add button and in the form is my update row.

If you can help me to add the xml fields to with my onclick function that will be greatly appreciated

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        UltraWebGrid1.Rows.Add()
 Private Sub UltraWebGrid1_UpdateRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles UltraWebGrid1.UpdateRow
 
        Dim oldRow As UltraGridRow = CType(e.Data, UltraGridRow)
 
        Dim dataKey As String = CStr(e.Row.DataKey)
 
        'newer fields
        'Dim ID As String = e.Row.Cells(0).Value
        'Dim PackSize As String = e.Row.Cells(1).Value
        'Dim Description As String = e.Row.Cells(2).Value
        'Dim Description As String = e.Row.Cells(2).Value
 
 
        Dim sUnitPrice As String = e.Row.Cells(3).Value
        Dim sSRP As String = e.Row.Cells(5).Value
        Dim CasePrice As Decimal
        'Dim sCasePrice As String = e.Row.Cells(4).Value
 
        If Not IsNumeric(sUnitPrice) Then
            With lblMessage
                .Visible = True
                .CssClass = "labelRed"
                .Text = "Last Price field must be numeric! Your data is not saved. Please reenter your Last Price."
            End With
            Exit Sub
        ElseIf Not IsNumeric(sSRP) Then
            With lblMessage
                .Visible = True
                .CssClass = "labelRed"
                .Text = "Current Price field must be numeric! Your data is not saved. Please reenter your Current Price."
            End With
            Exit Sub
        End If
 
        Dim ds As DataSet = CreateDataSource()
        Dim row As DataRow = ds.Tables(0).Rows(e.Row.Index)
 
        row("ID") = ID
        ' row("pack.size") = PackSize
        'row("Description") = Description
 
        If IsNumeric(sUnitPrice) Then
            CasePrice = Convert.ToDecimal(e.Row.Cells(7).Value) * Convert.ToDecimal(sUnitPrice)
            row("case_price") = System.Decimal.Round(CasePrice, 2)
        End If
 
        'row("case_price") = sCasePrice
 
        row("SRP") = sSRP
 
        ds.WriteXml(_XmlPreview)
 
        Me.UltraWebGrid1.DisplayLayout.SelectedRows.Clear()
 
        With UltraWebGrid1
            '.EditItemIndex = -1
            .DataSource = CreateDataSource().Tables(0)
            .DataBind()
        End With
 
        With lblMessage
            .Visible = True
            .CssClass = "labelGreen"
            .Text = "Your data was succesfully modified and saved."
        End With
    End Sub

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20823716
I am trying to say that if you bind the UltraWebGrid to the same DataSet, then it should keep that up-to-date, and then you can use ds.WriteXml() to save the XML.

Bob
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 9

Author Comment

by:Seven price
ID: 20823803
Ok maybe we are having a simple misunderstanding. Ok i can save the updated info. but if I add a new row and is not a blank xml tag for example

this is bounded
 <item ID="109" case.size="60" pack="DOZ" pack.size="60/6 PK 30 DOZ">
    <company>East Coast Egg Farmers (888) 240-5788</company>
    <description>6pk WHITE EGGS</description>
    <unit_price />
    <case_price>180</case_price>
    <SRP>3</SRP>
  </item>

but if I add a new row  I need the addrow button to create this below before my next information is added,
 <item ID=" case.size="" pack="" pack.size=">
    <company></company>
    <description></description>
    <unit_price />
    <case_price></case_price>
    <SRP></SRP>
  </item>

The information will save to the xml if i have these blank tags in the xml already because it will show up in the datagrid as a blank column until i add some value. But I want if I click the addrow button these fields will create as the addrow button creates a new row.
hope that gives it more clarity.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20823893
I clearly don't understand what you are talking about.  Are you now saying that if you add a new row, and create the XML file, that the attributes and the element inner text is empty, and you don't want it to be?

Bob
0
 
LVL 9

Author Comment

by:Seven price
ID: 20823992
Exactly  I can add a newrow because that is infragistics, one of there components when you intialize onload. but when I fill in the columns It will not allow me to insert information because I have to add the xml tags before inserting new inforamtion in the datagrid and the xml table. pic below.


If you see the pic i have 2 blank column rows that is because i clicked the add row button. pic 10.49

but after adding a row i click on the image on the left and a pop up appears with blank fields, I can fill in these fields but ((pic2))

pic3  10.50 i get this error because there is not blank tag row within the xml.

Let me know if that helps.
So i want to have something in vb when i click on my addrow button it will give me those blank fields above so when i hit save the data will save in those blank fields.


ScreenHunter-01-Feb.-05-10.49.gif
ScreenHunter-02-Feb.-05-10.50.gif
ScreenHunter-03-Feb.-05-10.52.gif
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20824026
>>It will not allow me to insert information because I have to add the xml tags
before inserting new inforamtion in the datagrid and the xml table

It looks like you are binding the UltraWebGrid to a DataSet, so I also don't understand what you mean by this statement, since you aren't bound to the XML file.

Bob
0
 
LVL 9

Author Comment

by:Seven price
ID: 20824054
Well I will rephrase that. Or lets scratch that. but you are correct I am using a dataset but I am not sure how to insert tags into my xml. this function should work when I click the addrow button.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1500 total points
ID: 20825026
I don't think that you need to insert tags into your XML, I just think that you need to set values for a DataRow for the DataTable that is bound from the DataSet to the grid.

Bob
0
 
LVL 9

Author Comment

by:Seven price
ID: 20825274
Do you have example or code to what i need to do
0
 
LVL 9

Author Comment

by:Seven price
ID: 20825323
somthing like this
Private Sub btnUpdate_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles btnUpdate.Click
        Dim ds As New DataSet()
        Try
            'Refill the dataset
            ds.ReadXml(Server.MapPath(".") & "/Data/fluid.xml")
            'Make the Updates
            'ds.Tables(0).Rows(0).Item("PartID") = lblPartID.Text
            ds.Tables(0).Rows(0).Item("title") = ddltitle.Text
            ds.Tables(0).Rows(0).Item("subtitle") = ddlSubtitle.Text
            ds.Tables(0).Rows(0).Item("info") = ddlinfo.Text
            'Me.CustomerNameTextBox.SetBinding(TextBox.TextProperty, binding)
            With Lblmessage
                Lblmessage.Visible = True
                .CssClass = "labelRed"
                .Text = "Your Xml file has been updated"
            End With
            'ds.Tables(0).Rows(0).Item("Color") = ddlColors.SelectedItem.Text
            ' ds.Tables(0).Rows(0).Item("Manufacturer") = ddlManufacturer.SelectedItem.Text
            ' ds.Tables(0).Rows(0).Item("Price") = ddlPrice.SelectedItem.Text
            'Write the updated dataset as an xml file.
            ds.WriteXml(Server.MapPath(".") & "/Data/fluid.xml", _
            XmlWriteMode.WriteSchema)
            'Display the updated data in the Datagrid
            Datagrid1.DataSource = ds
            Datagrid1.DataBind()
            'ds.Fill(ds, "test")
 
            'ddltitle.Text = ds.GetXml
 
            'ddltitle.DataSource = ds.Tables.ToString()
        Catch
            'Redirect to Error Page or take other action to handle error.
        Finally
            ds.Dispose()
        End Try
    End Sub

Open in new window

0
 
LVL 9

Author Comment

by:Seven price
ID: 20832814
>>>>I don't think that you need to insert tags into your XML, I just think that you need to set values for a DataRow for the DataTable that is bound from the DataSet to the grid.

I have one question and I understand you like fool because i am a newbie to vb but are you saying add this on the page load event. I cannot add values on the onclick add event?

can you please show me example in my code and I will end this. thanks.

Imports System.Data
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Xml.XPath
Imports System.Web.UI.WebControls
Imports System.Text
Imports System.IO
Imports Infragistics.WebUI.UltraWebGrid
 
Public Class NewEggInputForm
    Inherits System.Web.UI.Page
 
#Region " Web Form Designer Generated Code "
 
    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
 
    End Sub
    Protected WithEvents lblMessage As System.Web.UI.WebControls.Label
    Protected WithEvents lblSaleDate As System.Web.UI.WebControls.Label
    Protected WithEvents txtSaleDate As System.Web.UI.WebControls.TextBox
    Protected WithEvents lblComment As System.Web.UI.WebControls.Label
    Protected WithEvents igtbl_TextBox_1_0 As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtComment As System.Web.UI.WebControls.TextBox
    Protected WithEvents btnPreview As System.Web.UI.WebControls.Button
    Protected WithEvents UltraWebGrid1 As Infragistics.WebUI.UltraWebGrid.UltraWebGrid
    Protected WithEvents WebAsyncRefreshPanel1 As Infragistics.WebUI.Misc.WebAsyncRefreshPanel
    Protected WithEvents BtnClearAll As System.Web.UI.WebControls.Button
    Protected WithEvents WebAsyncRefreshPanel2 As Infragistics.WebUI.Misc.WebAsyncRefreshPanel
    Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    Protected WithEvents Button2 As System.Web.UI.HtmlControls.HtmlInputButton
 
    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object
 
    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub
 
#End Region
 
#Region " Declarations "
 
    ' User Controls -   Menu
 
    ''Private _XmlOutput As String = Server.MapPath("Data\EggPricingOutput.xml")
    Private _XmlInput As String = Server.MapPath("Data\EggPricingTemplate.xml")
    Private _XmlPreview As String = Server.MapPath("Data\EggPricingPreview.xml")
 
#End Region
    Dim sTemp As Integer = Nothing
 
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        If Not IsPostBack Then
            ShowFormOnScreen()
        End If
    End Sub
 
    Private Function InitFiles() As Boolean
        '
        Try
            If Not System.IO.File.Exists(_XmlPreview) Then
                System.IO.File.Copy(_XmlInput, _XmlPreview)
            End If
            Return True
        Catch ex As Exception
            Return False
        End Try
        '
    End Function
 
    Private Function CreateDataSource() As DataSet
        '
        Dim xml As New XmlDataDocument
        '
        xml.DataSet.ReadXmlSchema(_XmlPreview)
        xml.Load(_XmlPreview)
        '
        Return xml.DataSet
        '
    End Function
 
    Private Sub ShowFormOnScreen()
        '
        lblMessage.Visible = False
 
        Try
            If InitFiles() Then
 
                Dim ds As DataSet = CreateDataSource()
                '
                With UltraWebGrid1
                    .DataSource = ds.Tables(0)
                    .DataBind()
                End With
 
                txtSaleDate.Text = ds.Tables(1).Rows(0).Item(0).ToString
                txtComment.Text = ds.Tables(1).Rows(0).Item(1).ToString
            Else
                With lblMessage
                    .Visible = True
                    .CssClass = "labelRed"
                    .Text = "File can NOT be created. Please contact the A1S help desk at (914) 697-5357."
                End With
 
            End If
 
        Catch ex As Exception
 
            With lblMessage
                .Visible = True
                .CssClass = "labelRed"
                .Text = "An error occurred. Please contact the A1S help desk at (914) 697-5357."
            End With
 
        End Try
 
        '
    End Sub
    Public Sub doClearAll()
 
        Dim ds As DataSet = CreateDataSource()
        Dim row As DataRow
 
        For Each row In ds.Tables(0).Rows
            row("unit_price") = ""
            row("case_price") = ""
            row("SRP") = ""
        Next
 
        ds.WriteXml(_XmlPreview)
 
        'sTemp = 5
 
        With UltraWebGrid1
            '.EditItemIndex = -1
            .DataSource = CreateDataSource().Tables(0)
            .DataBind()
        End With
 
        txtSaleDate.Text = ""
        txtComment.Text = ""
        Me.lblMessage.Text = ""
        Me.UltraWebGrid1.DisplayLayout.SelectedRows.Clear()
        '
 
    End Sub
 
    Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
        '
        If ConstractXML() Then
            Session("rtnPage") = "/dairy/EggInputForm.aspx"
            Response.Redirect("/dairy/Preview.aspx")
        End If
        '
    End Sub
 
    Private Function ConstractXML() As Boolean
        '
        ' Add comment and date fields to xml 
        '
        Dim ds As DataSet
        '
        Try
            ds = CreateDataSource()
 
            ds.Tables(1).Rows(0).Item(0) = txtSaleDate.Text
            ds.Tables(1).Rows(0).Item(1) = txtComment.Text
 
            ds.WriteXml(_XmlPreview)
 
            Return True
 
 
        Catch ex As Exception
            Response.Write(ex.Message)
            Response.Write("<br/><font color='red' >Error occurred.Preview file has not been created.</font>")
            Return False
 
        Finally
 
        End Try
 
        '
    End Function
    Private Sub UltraWebGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles UltraWebGrid1.InitializeLayout
        UltraWebGrid1.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes
        UltraWebGrid1.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes
        UltraWebGrid1.Bands(0).Columns.FromKey("ID").Move(0)
        UltraWebGrid1.Bands(0).Columns.FromKey("pack.size").Move(1)
        UltraWebGrid1.Bands(0).Columns.FromKey("Description").Move(2)
        UltraWebGrid1.Bands(0).Columns.FromKey("unit_price").Move(3)
        UltraWebGrid1.Bands(0).Columns.FromKey("case_price").Move(4)
        UltraWebGrid1.Bands(0).Columns.FromKey("srp").Move(5)
 
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(6).Hidden = True
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(7).Hidden = True
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(8).Hidden = True
 
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(0).Header.Caption = "ID"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(1).Header.Caption = "Pack/Size"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(2).Header.Caption = "Description"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(3).Header.Caption = "Unit Price"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(4).Header.Caption = "Case Price"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(5).Header.Caption = "SRP"
 
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(0).Key = "ID"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(1).Key = "pack.size"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(2).Key = "Description"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(3).Key = "unit_price"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(4).Key = "case_price"
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(5).Key = "SRP"
 
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(0).Width = Unit.Pixel(100)
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(1).Width = Unit.Pixel(100)
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(2).Width = Unit.Pixel(430)
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(3).Width = Unit.Pixel(100)
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(4).Width = Unit.Pixel(100)
        UltraWebGrid1.DisplayLayout.Bands(0).Columns(5).Width = Unit.Pixel(100)
 
        ' set the DataKeyField so when the events are thrown the
        ' row.datakey property can be populated
 
        e.Layout.Bands(0).DataKeyField = "GUID"
        ' turn on edit, update, delete and show the AddNewBox
        e.Layout.AllowAddNewDefault = Infragistics.WebUI.UltraWebGrid.AllowAddNew.Yes
        e.Layout.AllowDeleteDefault = Infragistics.WebUI.UltraWebGrid.AllowDelete.Yes
        e.Layout.AllowUpdateDefault = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes
        UltraWebGrid1.DisplayLayout.AddNewBox.Style.BackColor = Color.BlanchedAlmond
        e.Layout.AddNewBox.Hidden = False
        ' set the default cell click action to edit
        e.Layout.CellClickActionDefault = _
        Infragistics.WebUI.UltraWebGrid.CellClickAction.Edit
        e.Layout.CellClickActionDefault = _
        Infragistics.WebUI.UltraWebGrid.CellClickAction.CellSelect
        ' add a hidden GUID column to band(0)
        With e.Layout.Bands(0)
            Dim objTable As DataTable = New DataTable
            Dim objRow As DataRow
            .Columns.Add("GUID")
           
            .Columns.FromKey("GUID").Hidden = True
 
           
 
            ' .Rows.Add(objRow)
            '   Next i
        End With
 
    End Sub
 
 
  
 
 
    Private Sub UltraWebGrid1_UpdateRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles UltraWebGrid1.UpdateRow
 
        Dim oldRow As UltraGridRow = CType(e.Data, UltraGridRow)
 
        Dim dataKey As String = CStr(e.Row.DataKey)
 
        'newer fields
        'Dim ID As String = e.Row.Cells(0).Value
        'Dim PackSize As String = e.Row.Cells(1).Value
        'Dim Description As String = e.Row.Cells(2).Value
        'Dim Description As String = e.Row.Cells(2).Value
 
 
        Dim sUnitPrice As String = e.Row.Cells(3).Value
        Dim sSRP As String = e.Row.Cells(5).Value
        Dim CasePrice As Decimal
        'Dim sCasePrice As String = e.Row.Cells(4).Value
 
        If Not IsNumeric(sUnitPrice) Then
            With lblMessage
                .Visible = True
                .CssClass = "labelRed"
                .Text = "Last Price field must be numeric! Your data is not saved. Please reenter your Last Price."
            End With
            Exit Sub
        ElseIf Not IsNumeric(sSRP) Then
            With lblMessage
                .Visible = True
                .CssClass = "labelRed"
                .Text = "Current Price field must be numeric! Your data is not saved. Please reenter your Current Price."
            End With
            Exit Sub
        End If
 
        Dim ds As DataSet = CreateDataSource()
        Dim row As DataRow = ds.Tables(0).Rows(e.Row.Index)
 
 
        If IsNumeric(sUnitPrice) Then
            CasePrice = Convert.ToDecimal(e.Row.Cells(7).Value) * Convert.ToDecimal(sUnitPrice)
            row("case_price") = System.Decimal.Round(CasePrice, 2)
        End If
 
        row("SRP") = sSRP
 
        ds.WriteXml(_XmlPreview)
 
        Me.UltraWebGrid1.DisplayLayout.SelectedRows.Clear()
 
        With UltraWebGrid1
            '.EditItemIndex = -1
            .DataSource = CreateDataSource().Tables(0)
            .DataBind()
        End With
 
        With lblMessage
            .Visible = True
            .CssClass = "labelGreen"
            .Text = "Your data was succesfully modified and saved."
        End With
    End Sub
 
    
 
 
 
    Private Sub UltraWebGrid1_UpdateGrid(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UpdateEventArgs) Handles UltraWebGrid1.UpdateGrid
        Dim table As DataTable
        Dim row As UltraGridRow
       
 
 
    End Sub
    Private Sub BtnClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnClearAll.Click
        Call doClearAll()
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ds As New DataSet
        ds.Tables(1).Rows(0).Item(0) = txtSaleDate.Text
        ds.Tables(1).Rows(0).Item(1) = txtComment.Text
        ds.WriteXml(_XmlPreview)
 
        ds.WriteXmlSchema("EggPricingPreview.xml")
        If ds.Tables.Count = 0 Then
            With lblMessage
                .Visible = True
                .CssClass = "labelRed"
                .Text = " There is no file located Please add a file to create your data"
            End With
            Exit Sub
 
            
        End If
        
 
    End Sub
 
 
 
 
 
 
 
    '  ds.ReadXml(Server.MapPath(".") & "test.xml")
    '  ds.Tables(0).Rows().Item("ItemId") = (0).ToString
    'ds.Tables(0).Rows().Item("pack") = igtbl_TextBox_1_1.Text
    ' ds.Tables(0).Rows().Item("pack.size") = igtbl_TextBox_1_7.Text
    ' ds.Tables(0).Rows().Item("company") = igtbl_TextBox_1_5.Text
    ' ds.Tables(0).Rows().Item("unit_price") = igtbl_TextBox_1_5.Text
    ' ds.Tables(0).Rows().Item("case_price") = igtbl_TextBox_1_5.Text
    ' ds.Tables(0).Rows().Item("SRP") = igtbl_TextBox_1_5.Text
 
 
 
 
 
 
 
End Class

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20842100
I don't have any code examples, and I am not quite sure that I understand your full requirement.  It might help to explain at a high level what you are hoping to achieve.

Bob
0
 
LVL 9

Author Comment

by:Seven price
ID: 20843549
I just want to add a row in my xml table with the same fields, that is why i gave you the error above.

something like this but modified with my code.
Private Sub InsertRecord(theGridRow As UltraGridRow)
    Dim theCategory As CategoriesRow
    theCategory = NorthwindDataSet.Categories.NewCategoriesRow( )
    theCategory.CategoryName = theGridRow.Cells.FromKey(CategoryName).Value.ToString( )
    theCategory.Description = theGridRow.Cells.FromKey(Description).Value.ToString( )
    NorthwindDataSet.Categories.Rows.Add(theCategory)
    Me.SqlDataAdapterCategories.Update(NorthwindDataSet.Categories)
    theGridRow.Cells.FromKey(CategoryID).Value = theCategory.CategoryID
End Sub

Open in new window

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20843759
This is what I was thinking:

1) Bind a DataSet to the grid

2) Add a row to the grid

3) Save the DataSet to an XML file.

4) At the point of adding a row to the grid, there wouldn't be any XML involved, just a DataRow that belongs to a DataTable that belongs to the DataSet.

Bob
0
 
LVL 9

Author Comment

by:Seven price
ID: 20843903
The is correct on number 4 but when i click on the edit, that edits the blank row and hit ok i get that error. So I did number 1) and 2) but I need number 3)
0
 
LVL 9

Author Comment

by:Seven price
ID: 20844073
now the xml files that do exist in the xml are bounded and i can use the update control to update the info.
but again it is the new info i am trying to add. work with me. try to understand the concept, this is becoming repetitive.
0
 
LVL 9

Author Comment

by:Seven price
ID: 20852860
xml
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Native ability to set a user account password via AD GPO was removed because the passwords can be easily decrypted by any authenticated user in the domain. Microsoft recommends LAPS as a replacement and I have written an article that does something …
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question