Inheriting Typed DataSets and DataTables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I’m having trouble with Typed Dataset
I would like to add functionality to my typed dataset at the business layer such as delete rules or editing rules by inheriting it

Can I inherit the datatable? I’m having trouble because of the constructor
Can I override the row change event routines? How do I do that

How can I control these features in a typed dataset without my presentation layer having to do it
 
H

You can Inherit the DataTable Class and also it is possible to call the constructor of the Derived class. And it is possible to override the rowchange event routine by creating an event in your derived class and fire the event when rowchange event of the datatable fires

Sooraj P
Microsoft India Community Star
 
H

I want add one more thing. When you inherit the DataTable the OnRowChanging Event will be listed in Overrides. So it is easy to Override the event. Example

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Clic
Dim t As MyTabl
t = New MyTabl
t.TableName = "Employee
t.Columns.Add(New DataColumn("EmployeeName", GetType(String))
Dim dr As DataRo
dr = t.NewRow(
dr(0) = "Mike
t.Rows.Add(dr
dr = t.NewRow(
dr(0) = "William
t.Rows.Add(dr
MessageBox.Show(CType(t.Rows(0)(0), String)
End Su

Public Class MyTabl
Inherits DataTabl
Public Sub New(
MyBase.New(
End Su
Protected Overrides Sub OnRowChanging(ByVal e As System.Data.DataRowChangeEventArgs
MessageBox.Show("Row change"
End Su
End Class
 
I see your example works but my question was inheriting the datatable of a Typed Dataset
The constructor is presenting a problem because it is declared Friend. If I change it to Public it works. I really don't want to get into changing the generated code

Just getting to the RowChanged sub routine is good enough but, can I get to that without inheriting the Typed DataTable

I also do not want any of this business logic in the presentation layer where I realize I can hook into the events
 
Back
Top