473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Method Question?

I have the following situation.

I am creating my own user control.
This asp.net user control will have a method called "Read". When this
method is being called from the page. It will read line by line threw a
list dictionary. While reading line by line
it will be setting public properties that my page can access. So my user
control will look like this.

Usercontrol.ascx

public class clsUserControl
{
private string strMyPropertyValue;

public bool Read()
{
foreach(ListDictionary MyListRow in MyListDictionary)
{
strMyPropertyValue = (string)MyListRow.Value;
}
}

public string MyReturnedValue
{
set
{
MyReturnedValue = strMyPropertyValue;
}
}
}

Now, my webpage called webpage.aspx.
Will do the following.

public class clsMyWebPage
{
//This will reference my usercontrol on the webpage.
protected clsUserControl MyUserControl;

private void DoSomething()
{
string strGetValue;
while(MyUserControl.Read())
{
strGetValue = MyUserControl.MyReturnedValue;
}
}
}

My question is this. How do I get my ".Read" method to loop through each
row setting the public property for each new value it retrieves
from the ListDictionary? Also, meanwhile setting the .Read method to
"true" so the calling page while loop will keep looping? I hope this makes
sense.

Thanks,
Mark

Nov 19 '05 #1
2 1183
Where oh where to begin?...

Have you ever done any programming? It looks to me like you're putting the
cart before the horse here. In this case, the cart is writing a program, and
the horse is learning to program. Without the horse, the cart is pretty much
useless.

You have a Method named "Read()" that returns a boolean value. However, it
doesn't return anything! In addition, I'm not at all sure what you expect
this function to do. As it stands, it will always assign strMyPropertyValue
the value of the last "ListDictionary" item in the "ListDictionary." The
whole loop thing is pointless.

After that, you define a Property with only a Setter, no getter. This means
that you can NEVER read the value of the property, although in one line of
code you attempt to.

IOW, this code is one big cluster-f**k.

As to your question:
My question is this. How do I get my ".Read" method to loop through each
row setting the public property for each new value it retrieves
from the ListDictionary?
That's exactly what it does. See my earlier remark.
Also, meanwhile setting the .Read method to
"true" so the calling page while loop will keep looping?
Um. No. The boolean value of the Read Method is a RETURN value. Setting it
is not something a program can do.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"SouthSpawn" <so********@aol.com> wrote in message
news:31******************************@localhost.ta lkaboutsoftware.com...I have the following situation.

I am creating my own user control.
This asp.net user control will have a method called "Read". When this
method is being called from the page. It will read line by line threw a
list dictionary. While reading line by line
it will be setting public properties that my page can access. So my user
control will look like this.

Usercontrol.ascx

public class clsUserControl
{
private string strMyPropertyValue;

public bool Read()
{
foreach(ListDictionary MyListRow in MyListDictionary)
{
strMyPropertyValue = (string)MyListRow.Value;
}
}

public string MyReturnedValue
{
set
{
MyReturnedValue = strMyPropertyValue;
}
}
}

Now, my webpage called webpage.aspx.
Will do the following.

public class clsMyWebPage
{
//This will reference my usercontrol on the webpage.
protected clsUserControl MyUserControl;

private void DoSomething()
{
string strGetValue;
while(MyUserControl.Read())
{
strGetValue = MyUserControl.MyReturnedValue;
}
}
}

My question is this. How do I get my ".Read" method to loop through each
row setting the public property for each new value it retrieves
from the ListDictionary? Also, meanwhile setting the .Read method to
"true" so the calling page while loop will keep looping? I hope this makes
sense.

Thanks,
Mark

Nov 19 '05 #2
Kevin,

It looks to me, as you are a typical programmer. NO PEOPLE SKILLS WHAT SO
EVER. WHILE I AM TRYING.
Another developer help me solved my problem. He at least knew how to help
people without trying to talk smack. Here is the solution I needed.

public class clsUserControl
{
IDictionaryEnumerator enumerator =
MyListDictionary.GetEnumerator();

public bool Read()
{
return enumerator.MoveNext();
}

public string MyReturnedValue
{
get
{
return enumerator.Value.ToString();
}
}
}

You might be an Microsoft MVP, and that's all you will ever be.

Mark

Nov 19 '05 #3

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

Similar topics

4
by: Ruud de Jong | last post by:
The question I have is: how safe / future proof / portable is the use of the __subclasses__ method that exists for new-style classes? Background: I thought I had found an easy-to-understand...
7
by: Edward Diener | last post by:
This simple code example gives me the message, "TypeError: 'staticmethod' object is not callable". class X(object): def Y(x): print x Y = staticmethod(Y) ad = { 1 : Y } def Z(self):...
1
by: Oriane | last post by:
Hi, I'm currently a method attribute which is used to check the "validity" of this method against a rule. I wrote the isValid method, to be used inside the otriginal method: For instance: //...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
9
by: Steve Richter | last post by:
in a generic class, can I code the class so that I can call a static method of the generic class T? In the ConvertFrom method of the generic TypeConvert class I want to write, I have a call to...
1
by: =?Utf-8?B?dG9iaXdhbl9rZW5vYmk=?= | last post by:
In the following code, calling CallTestMethod() from an instance of the derived class (the base is abstract and we can never instantiate it), referencing 'base.TestMethod()' actually calls...
10
by: Ugo | last post by:
Hi guys, until now I make so: <div id="my_div"><!-- content --></div> MyClass.prototype.doSomething = function( ) {}; MyClass.prototype.assignFun = function( )
2
by: groups.kellyg | last post by:
If I have a web method called Log() and on the client I call BeginLog() with a null value for the AsyncCallback, will this cause a problem? I want to periodically Log messages to a Log web service...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.