473,574 Members | 3,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DefaultValueAtt ribute Not Working

I've create a custom DataGridColumnS tyle and when I try to assign a
DefaultValue to a property, it doesn't seems to have any effect.

Here is the code:

[DefaultValue(10 )]
public int Test
{
get{return 0;}
set{}
}

the default value shown is 0 instead.
I also tried [DefaultValue(ty peof(int), "10")] with no effect.

Thanks,
Homa Wong

Jul 21 '05 #1
3 1935
Well, your Getter is always returning 0, isn't it?

"Homa" <ho******@yahoo .com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
I've create a custom DataGridColumnS tyle and when I try to assign a
DefaultValue to a property, it doesn't seems to have any effect.

Here is the code:

[DefaultValue(10 )]
public int Test
{
get{return 0;}
set{}
}

the default value shown is 0 instead.
I also tried [DefaultValue(ty peof(int), "10")] with no effect.

Thanks,
Homa Wong

Jul 21 '05 #2
Well, your Getter is always returning 0, isn't it?

"Homa" <ho******@yahoo .com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
I've create a custom DataGridColumnS tyle and when I try to assign a
DefaultValue to a property, it doesn't seems to have any effect.

Here is the code:

[DefaultValue(10 )]
public int Test
{
get{return 0;}
set{}
}

the default value shown is 0 instead.
I also tried [DefaultValue(ty peof(int), "10")] with no effect.

Thanks,
Homa Wong

Jul 21 '05 #3
That is just a test code. The actual code like this

[DefaultValue(10 0)]
public int MaxValue
{
get{return Convert.ToInt32 (txtValue.Text) ;}
}

With this, the designer report error because txtValue.Text is default
to "".
To the Convert.ToInt32 () fails.

It works only if I set the txtValue.Text to "100" in the constructor.

Also, even if I do a test code like this,
#region Property TestVal
#region Comments
/// <summary>
/// Private -
/// </summary>
#endregion
private int _TestVal = 0;
#region Comments
/// <summary>
/// Gets or Sets (Default = 0)
/// </summary>
#endregion
[DefaultValue(10 0)]
public int TestVal
{
get{return _TestVal;}
set{_TestVal = value;}
}
#endregion

it still returns 0 in the Designer instead of 100.

Homa

Brendan Green wrote:
Well, your Getter is always returning 0, isn't it?

"Homa" <ho******@yahoo .com> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
I've create a custom DataGridColumnS tyle and when I try to assign a
DefaultValue to a property, it doesn't seems to have any effect.

Here is the code:

[DefaultValue(10 )]
public int Test
{
get{return 0;}
set{}
}

the default value shown is 0 instead.
I also tried [DefaultValue(ty peof(int), "10")] with no effect.

Thanks,
Homa Wong


Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
832
by: Gianluca | last post by:
Properties of inherited controls have the default value set to the value that is assigned in the InitializeComponent method in the base form class. Which is correct and useful. In the derived form you can always select the "Reset" option and restore the inherited property. However, if you extend an existing control class, say Button, and...
0
1362
by: vthakur | last post by:
Hello: I have generated a c# proxy (client) from the WSDL. One of the class has a defaultValueAtribute. Like so: public class PersonInformationLoadRequest { public string DataSource;
2
5047
by: Mike in Paradise | last post by:
Can you use the DefaultValueAttribute on Decimal PropertyFields? If so what is format for setting the Default value. Thanks... Example /// <summary> /// Field: increment value /// </summary>
5
2799
by: Martin Heuckeroth | last post by:
Hi We are working on a webservice application and are having some problems with the cookies and/or sessions. We have them working on our intranet but then its not working on the internet. We have been looking our asses off but can not find a working solution. the code we came up with is ...
5
3049
by: tshad | last post by:
I have been working with setting my drop boxes to allow double clicking to select an item. It worked fine until I made some changes. I then stripped the page down to the bare essentials to find out why it quit working. I found that if I didn't have a linkbutton, it quit working????????? If I changed the linkbutton to a regular button,...
8
2507
by: jojobar | last post by:
Okay, I am trying to do is to test the webresource in 2.0 1. I created a new project with assembly name (and default assembly name) "Office". 2. I added the following to the AssemblyInfo.cs file (present under the Properties folder of the project) 3. Now I created a file called test.js on the root folder of the project,
2
14816
by: Don | last post by:
I'm having problems with intellisense, autocomplete, etc. suddenly not working in certain classes of a project I'm working on. All the options are set, and it all works fine for most classes, but for some it just suddenly stopped working. After a build it'll work maybe once or twice, then stop. I've tried repairing my installation of Visual...
9
3200
by: MSDNAndi | last post by:
Hi, I have a set of simple webservices calls that worked fine using .NET Framework 1.0. I am calling a Java/Apache based webservices, the calling side is not able to supply a proper WSDL. What it does is to call a webservice with two parameters, one being a integer, the other one being a "String" which contains XML (not the best...
1
3164
by: Mythran | last post by:
How can I set a DefaultValue for an array property? I don't have a project that uses this anymore, but still am curious. Of all the replies I've posted here, a simple thing like this is my "gotcha!". :***( I have a TypeConverter class that inherits from ArrayConverter and it parses a string into an integer-array. The property that...
2
1643
by: --== Alain ==-- | last post by:
Hi, I would like to define the default value of my property. My property is from type Bitmap^, therefore i was thinking to do : but i does not work. how is it possible to define this property to no pointer ?
0
7841
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8101
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8271
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5335
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2273
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1099
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.