.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Class Property, using Set

Posted By:      Posted Date: September 21, 2010    Points: 0   Category :ASP.Net

My class uses a dataset and a property to "get" and "set" the rows in a SQL table called GROUPS into a class table called tblGroups.  In my constructor I select the contents of the GROUPS datatable and use the "Set" code in the property to populate tblGroups as follows"

Here is the property in the class:

    Private tblGroups As DataTable = New DataTable

    Public Property Groups() As DataTable
            Groups = tblGroups
        End Get
        Set(ByVal value As DataTable)
            tblGroups = value
        End Set
    End Property


Constructor Code:

Groups = ds.Tables("Groups")



When instantiating a new class object the set code above does a fine job of loading any existing records into my tblGroups table.  Now I wish to add additional records into that table.  What is the best way to accomplish this?

  • Do I need to create a seperate method to handle this, or should I change the existing "set" code somehow?
  • If the answer is to change the "set" code, can I add additional byVal variables?
  • If so, then how do I accomplish that without c

    View Complete Post

More Related Resource Links

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

SelectMethod property missing from DomainDataSource class

I have an issue using WCF RIA with ASP.NET. I can't find the SelectMethod property of the Microsoft.Web.UI.WebControls.DomainDataSource class. What happened to this property? Am I using the wrong class?  I'm using VS2010 with the latest versions of Silverlight 4 Tools and RIA Services Toolkit installed. Any help with this would be greatly appreciated. Cheers, Simon

how to get the value of a class property using reflection?

i have a class like this..public class MyClass{List<ValueObjectClass> SampleList {get; set;}...}how can i get the value of MyClass.SampleList using reflection and convert it to List<T>?thanks..

how to change button backcolor property on a form from a class file


Hello friends,

I am having a problem of updating the main form button backcolor property from another class. I have attahced the code. Please tell how can i rectify this problem.

PopUp is another class, in which i want that when ToolStripDropDown closes it change the form button BackColor from Orange to WhiteSmoke.


public partial class PopUp : ToolStripDropDown


        public PopUp()





        protected override void OnClosed(ToolStripDropDownClosedEventArgs e)


               Form1 f1 = new Form1();

              // f1._pushed = false;

       f1.Controls["button1"].BackColor = Color.WhiteSmoke;





It seems that this line works, i checked it using MessageBox it changes the backcolor property but it does not updated to the form displayed on the screen. 

Can anyone help me

class contains non-dependency-property data members that are DependencyObject objects, you must also


I was reading the article Freezable Objects Overviewand came acrosee the statement

"If  your class contains non-dependency-property data members that are DependencyObject objects, you must also call the OnFreezablePropertyChanged method each time you change on of their values, even if you're setting the member to null. "

I quite do not understand the part about non-dependency-property data members that are DependencyObject objects. Can some one explain exactly what this means? If a data member is derived from the DependencyObject  class how then can the data member be a non dependency property?

I am also trying to locate some source code / project that overrides the OnFreezablePropertyChanged method, and have yet to find any on the interenet.

If anyone know whe

2010 Collection class syntax/property problem

I converted a project from 2008 to 2010 to be able to use the TPL.

I've updated the compile target to .NET 4. Everything seems good, including the .NET 4 specific TPL stuff...except that:

Parallel.ForEach(MyClassCollection.Cast(Of MyClass), (Sub(ANYTHING As MYClass) ANYTHING.MySubRoutine()))

Gives the following as a syntax error:

Error 2 'Cast' is not a member of 'Microsoft.VisualBasic.Collection'. C:\Users\jeff\Documents\Visual Studio 2010\Projects\MyProject\MyProject\RunLoop.vb 229 34 MyProject

Any ideas?


How to get child property inside parent class, with lambda?


Hi all,

Could you answer me how to do next, please? How to do this with Lambda? Is it possible to delegate some object instance and use its properties and methods in case if this method doesn't know type of delegated object?

class class_a {
    public string getChildData<T> (T dynamicInstance) {
        return dynamicInstance.prop;

class class_b : a {
    public string prop = "prop_b";

class class_c : a {
    public string prop = "prop_c";

var inst_b = new b ();
var inst_c = new c ();

Purpose : to get child property inside parent class?

Thanks, Artem

Problem retrieving bit colum with sqldatareader for vb class property


 I have a vb class that reads a single row of data from an SQL view. I want to add a property to it that will expose the value of a new bit field. But whatever I do my class always returns the value "false".

What am I doing wrong?

       Public ReadOnly Property IsPublished() As Boolean
                Return valPublished
            End Get
        End Property

Here's the relevant line from my datareader:
        Me.valPublished = Convert.ToBoolean(theObjectReader("Authorised"))Authorised is my bit field. I have tried it with and without the "ConvertToBoolean" statement.
When I response write the value of the property for rows where this field is true, it always shows false.

Any ideas?

How to set a style's TargetType property in XAML to a Generic Class?


I've just moved to .NET 4.0 / Visual Studio 2010 and am hoping there is a new answer to this question, found on StackOverflow from over a year ago:

Is it possible to set a style's TargetType property in XAML to a Generic Class?

public class Selector<T> : Control { }

and then in xaml

<Style x:TargetType="Selector">
<Setter Property="MyProperty" Value="Green" />

I found this on the WPF Tutorial, and would like to find a similar mechanism for this situation above.

<!-- XAML 2009 -->
<ObservableCollection x:TypeArguments="Employee">
 <l:Employee FirstName="John" Name="Doe" />
 <l:Employee FirstName="Tim" Name="Smith" />
</ObservableCollection />



lifespan of a property inside a static class in IIS



I want to know , how good / bad is it to save configuration values in a static properties?

I am creating an application which reads configuration from an XML file and a DataContext file, instead of sending the CustomConfig class into the configuration.xml each time I tought about using an ReadXml() method on application_start at the global.ascx

the ReadXml() method would save the data in static properties of CustomConfig and whereever I would want to read that particler data I would ask CustomConfig.PROERTY_NAME

My question is ? how smart it is ? how long does IIS would save the data in a static member? (if as long as the application exists then I'm ok as long as I add the ReadXml() in the application_start)

would like to hear your comment.. 

Using a List(of T) as a "Property" in a class


In my application I have a class called "RCategory" as illustrated here:

Public Class RCategory
    Public Property RCatNum As Integer
    Public Property RAct As Char
    Public Property RMin As Double
    Public Property RMax As Double
    Public Property RTyp As Char 
End Class

I have another class where I want to use a List (of RCategory) as a property, to-wit:

    Public Property RpStrt As Date
    Public Property RpEnd As Date 'Plan Year End
    Public Property RCat As List(Of RCategory)
    Public Property MinFee As Double


I'm trying to add to my list using the following code:

                        For ct As Integer = 1 To 8
                            Dim c As New RCategory With {.RCatNum = ct,
                                                         .RAct = dr("RACT" & ct.ToString).ToString,
                                                         .RTyp = dr("RTYP" & ct.ToString).ToString,
                                                         .RMax = CDbl(dr("RMAX" & ct.ToString))}
                            If ct = 4 Or ct = 5 Then
                                c.RMin = CDbl(dr("RMIN" & ct.ToString))

Inserting Property values of class into ParamArray parameters as object()


Hi All,

Using the properties as defined in a class, how about can I put them into the ParamArray parameters argument of my function.

The code as follows:

Public Class MyObject

   Public Property Prop1 as string

   Public Property Prop2 as integer

   Public Property Prop3 as Boolean

   Public Sub  AddNewMyObject

        MsSQL_ExecuteNonQuery("StoredProc_AddNewMyObject", ________________?)

   End Sub

End Class

Protected Function MsSQL_ExecuteNonQuery(ByVal storedProc as string, ByVal ParamArray parameters as object())

'Some Code here.

End Function

Please kindly help and advice.

Thank you in advance.

Warmest Regards,


WMI class Win32_PerfRawData_PerfProc_Process property PercentProcessorTime in physical and virtual m


Any insights on this would be greatly appreciated...

I am using Win32_PerfRawData_PerfProc_Process to query 'PercentProcessorTime', i.e., '% Processor Time' and cook it using the formula 100*((X1-X0)/(Y1-Y0)) to get the CPU utilization of a process (not the processor).

The experiment is conducted in a physical workstation and on a Virtual Machine. The outcome is really interesting. While it takes 0.005% on the physical workstation takes about 7% in the virtual machine...

Any idea on why this happens would be very helpful. Also would be interested to know the best way to collect CPU utilization of a process that runs in a virtual machine (guest OS).


How can I generate property set event with attribute class?


I want to code design like below;

class Sample
            public string Prop1

            void MyChangesDelegate()

is that possible?

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.

Creating a Simple Class in C#

The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend