أرجو المساعده
لدي صفحه في مشروعي هذه الصفحه تحتوي على 5
textbox
عندما أضع القيم في التيكس بوكس اريد ان أخزن القيم في ملف
xml
كيف تكوتن الطريقه
وبارك الله فيكم
أرجو المساعده
لدي صفحه في مشروعي هذه الصفحه تحتوي على 5
textbox
عندما أضع القيم في التيكس بوكس اريد ان أخزن القيم في ملف
xml
كيف تكوتن الطريقه
وبارك الله فيكم
ASP.Net Code
Dim ds As Data.DataSet
Dim path As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
'set path of file (on root of site)
path = Server.MapPath("xmlFile.xml")
'Creating new dataset
ds = New Data.DataSet("mydataset")
'Add an table to dataset
ds.Tables.Add("mytable")
'Add an column o datatable
ds.Tables("mytable").Columns.Add("myproperty")
'ceheck if file is exist
If IO.File.Exists(path) Then
'file is exist then read it
ds.ReadXml(path)
End If
'set grid to view content of datatable
GridView1.DataSource = ds.Tables("mytable")
'call this method to view changes on site
GridView1.DataBind()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'creating new row
Dim NewRow As Data.DataRow = ds.Tables("mytable").NewRow
'set row values
NewRow(0) = TextBox1.Text
'adding row to datatable
ds.Tables("mytable").Rows.Add(NewRow)
'save file
ds.WriteXml(path)
'clear text
TextBox1.Text = ""
'recall this method to view changes on site
GridView1.DataBind()
End SubVB.Net Code
Dim ds As Data.DataSet
Dim path As String = "xmlFile.xml"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Creating new dataset
ds = New Data.DataSet("mydataset")
'Add an table to dataset
ds.Tables.Add("mytable")
'Add an column o datatable
ds.Tables("mytable").Columns.Add("myproperty")
'ceheck if file is exist
If IO.File.Exists(path) Then
'file is exist then read it
ds.ReadXml(path)
End If
'set grid to view content of datatable
Me.DataGridView1.DataSource = ds.Tables("mytable")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'creating new row
Dim NewRow As Data.DataRow = ds.Tables("mytable").NewRow
'set row values
NewRow(0) = TextBox1.Text
'adding row to datatable
ds.Tables("mytable").Rows.Add(NewRow)
'save file
ds.WriteXml(path)
'clear text
TextBox1.Text = ""
End Subعذرا لم انتبه للقسم ...... ظننته قسم Asp.Net
على كل حال عدلت المشاركة وخليت الكودين
تم تعديل هذه المشاركة بواسطة blackeyes في 11 ديسمبر 2007 في 16:41
شكرأ لك وبارك الله فيك
انا بحثت لكن ليس بالاتجاه الصحيح
لا داعي للاعتذار قرات الكود واستطعت فهموا وتحويلوا
شكرا جزيلا لك مرتا اخرى
هذا الموضوع مغلق.
المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية
جارٍ التحقق من المتواجدين…