هلا اناعرفت كيف اعرض البيانات على داتا غريد من مصفوفة
بس المشكلة لما اضيف بيانات ما ينضاف الا صف واحد وبس ولما اضيف صف ثاني ما ينضاف طيب كيف ممكن اضيف واحذف البيانات على هذا الكود
اولا هذا كود الكلاس
Imports Microsoft.VisualBasic Public Class Contact Dim _ID As Integer Dim _name As String Dim _title As String Dim _company As String Dim _married As Boolean Public Property ID() As Integer Get ID = _ID End Get Set(ByVal Value As Integer) _ID = Value End Set End Property Public Property Name() As String Get Name = _name End Get Set(ByVal Value As String) _name = Value End Set End Property Public Property Title() As String Get Title = _title End Get Set(ByVal Value As String) _title = Value End Set End Property Public Property Company() As String Get Company = _company End Get Set(ByVal Value As String) _company = Value End Set End Property Public Property Married() As Boolean Get Married = _married End Get Set(ByVal Value As Boolean) _married = Value End Set End Property Public Overrides Function ToString() As String Return (_name) End Function End Class
وهذا كود الصفحة
Partial Class _Default Inherits System.Web.UI.Page Dim Contacts As New ArrayList() Dim c As New Contact Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' 'Load ' c.ID = 1 c.Name = "Sam" c.Company = "PIO" c.Title = "Sales Representative" c.Married = True Contacts.Add(c) Me.GridView1.DataSource = Contacts Me.GridView1.DataBind() End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' 'Add ' c.ID = TextBox4.Text c.Name = TextBox1.Text c.Company = TextBox1.Text c.Title = TextBox3.Text c.Married = True Contacts.Add(c) Me.GridView1.DataSource = Contacts Me.GridView1.DataBind() End Sub
ممكن حد يساعدني