|
Shani Natav wrote: Try using Session variables (Session["QueryList"])
Just shifting the problem from one storage mechanism to another. It still must be serializable.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You should be trying to store your data in viewstate anyway. ViewState should only be for small amounts of information, perhaps an ID to lookup the data again. Remember, viewstate is writtent ot he page so the larger it is the slower your pages will download and render.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
If you are facing problem with iterating the row then you can try the below code,
for (int rowCount = 0; rowCount < dataTable.Rows.Count;rowCount++ )
{
query.Add(dataTable.Rows[rowCount]);
}
ViewState["QueryList"] = query;
and reverse----
list = (ArrayList)ViewState["QueryList"];
for (int rowCount = 0; rowCount < list.Count; rowCount++)
{
DataRow dataRW = (DataRow)list[rowCount];
}
Have a good day...
~V
modified on Monday, August 23, 2010 9:35 AM
|
|
|
|
|
I hold some List of point ( List<point> ) and i need to find 2 point from this list
1. Point 1 - with the minimum X, Y value
2. Point 2 - with the maximum X, Y value
What is the best way to do it ?
Thanks.
|
|
|
|
|
Yanshof wrote: minimum X, Y value
Yanshof wrote: maximum X, Y value
Yanshof wrote: the best way
first define "minimum" and "maximum" for pairs of numbers: what if the points are (1,100) and (100,1)?
define "best", it is very subjective.
|
|
|
|
|
Lets say i need to find the most left up point as minimum and the most right down point as maximum...
|
|
|
|
|
and which would be which for the list (1,100) and (100,1)??
|
|
|
|
|
I'm not sure that helps: (0, 100) and (100, 0) are both "left up", and they are both equidistant from (0, 0). You need to think about it: Is it more important to be near the left, or near the top? When does it change? If you pick "Left" as most important is (1, 100) less than (2, 0)?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
To visualize Luc's answer, which point is closer to the upper left corner? Is it X or Y?
O O O O O
O O O O O
O O O X O
O O Y O O
O O O O O
X (4, 3):
(4*4) + (3*3) = 16 + 9 = 25
Distance to upperleft corner: 5
Y (3, 4):
(3*3) + (4*4) = 9 + 16 = 25
Distance to upperleft corner: 5
I are Troll
|
|
|
|
|
you cheated and changed my example!
|
|
|
|
|
Luc Pattyn wrote: you cheated and changed my example!
Extended it, adding comments like any student would
I are Troll
|
|
|
|
|
How about something like this
Func<Point, Point, double> distanceToken = new Func<Point, Point, double>((p1, p2) => { return ((p1.X - p2.X) * (p1.X - p2.X)) + ((p1.Y - p2.Y) * (p1.Y - p2.Y)); });
Point TopLeft = new Point() { X = 0, Y = 0 };
Point BottomRight = new Point() { X = 100, Y = 100 };
var t = (from pt in points
select new { p=pt, d= distanceToken (TopLeft, pt) }).OrderBy(a=>a.d);
Console.WriteLine("nearest topleft:" + t.First().ToString());
Console.WriteLine("farthest topleft:" + t.Last().ToString());
var t = (from pt in points
select new { p = pt, DistToA = distanceToken (TopLeft, pt), DistToB = distanceToken(BottomRight, pt) });
modified on Sunday, August 22, 2010 4:46 PM
|
|
|
|
|
cechode wrote: Math.Sqrt(Math.Pow(Math.Abs(p1.X - p2.X), 2) + Math.Pow(Math.Abs(p1.Y - p2.Y), 2))
Ok, no offence, but that's the worst way to do it.
First, never use Math.Pow to calculate trivial powers. It's very slow, and less accurate, compared to doing a couple of multiplications.
Second, that Math.Sqrt is just useless. All it does it take time. It doesn't change the order of the items.
Third, it's a square. What is that Math.Abs for?
If you combine the first two things, you don't even have to use any floating point.
Func distanceSquared = new Func((p1, p2) =>
{
return (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);
});
|
|
|
|
|
no offence taken. i learn by answering as well
you made some good points
|
|
|
|
|
i'm trying to draw a rectangle with in a panel and move it with in the panel,though i draw it i can't move it, i found the method ControlPaint.DrawReversibleFrame
but it draws in the screen not in the pannel
any idea hw to handle this
thanx in advance
|
|
|
|
|
Firstly, you need to handle the Panel Paint event. That way, each time the panel needs to draw, you will get told to do so. In the handler:
private Rectangle myRect = new Rectangle(0, 0, 40, 30);
private void myPanel_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawRectangle(Pens.Azure, myRect);
}
If you then change the position or size of myRect, just call myPanel.Invalidate() to force the panel to redraw. There is more complex stuff you may want, but that'll get you started on the basics.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
|
Well, i'm sure decorator pattern works in c#, but trying to post this from jave to c#,
no luck so far.
http://java-x.blogspot.com/2007/01/implementing-decorator-pattern-in-java.html
basically this line always gives me trouble, "Decorator decorator = new ConcreteDecorator(comp);"
------------------------------------------------------
import decorator.*;
public class Client {
public static void main(String[] args) {
IComponent comp = new Component();
Decorator decorator = new ConcreteDecorator(comp);
decorator.doStuff();
}
-------------------------------------------------------
BTW, i'm using abstract classes only, no interfaces.
Anyone knows a working example in c# ?
wow
|
|
|
|
|
5883 wrote: Anyone knows a working example in c# ?
Try here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Yes[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
The decorator pattern is used extensively in the Stream abstract class
and all it's sub classes. Read Here[^]
|
|
|
|
|
I want to know how can I prevent the form resizing when the user double clicks on the titlebar
|
|
|
|
|
You can't prevent it, but you can handle the event and cancel it or resize back the original.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|