Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2004

Tip: Looking for answers? Try searching our database.

Inheriting Typed DataSets and DataTables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ryan Shaw - 20 May 2004 02:31 GMT
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
Sooraj PM - 20 May 2004 08:16 GMT
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
Sooraj PM - 20 May 2004 08:21 GMT
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
Ryan Shaw - 20 May 2004 14:16 GMT
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
Cor Ligthert - 20 May 2004 13:18 GMT
Hi Ryan,

In my opinion a greath question for the newgroup

Adonet
<news://msnews.microsoft.com/microsoft.public.dotnet.framework.adonet>

Web interface:

<http://communities2.microsoft.com/communities/newsgroups/en-us/?dg=microsof
t.public.dotnet.framework.adonet>

I hope this helps a little bit?

Cor

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.