|
You are going to kick yourself for this!
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataRowView myDataRowView = (DataRowView)e.Row.DataItem;
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToSingle(myDataRowView["Difference"]) > 2.5)
{
((Image)e.Row.FindControl("ImageRating")).ImageUrl = "~/Images/Bad.png";
}
<big>else</big> if (Convert.ToSingle(myDataRowView["Difference"]) == 2.5)
{
((Image)e.Row.FindControl("ImageRating")).ImageUrl = "~/Images/Average.png";
}
else
{
((Image)e.Row.FindControl("ImageRating")).ImageUrl = "~/Images/Good.png";
}
}
}
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I can't believe I missed that!!
Its been driving me potty!
Once again many many thanks for your help
Andy
|
|
|
|
|
I told you you would kick yourself!
I would also consider re-writing your routine along the lines of:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataRowView myDataRowView = (DataRowView)e.Row.DataItem;
Single difference = Convert.ToSingle(myDataRowView["Difference"]);
Image image = e.Row.FindControl("ImageRating") as Image;
if (image != null)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (difference > 2.5)
{
image.ImageUrl = "~/Images/Bad.png";
}
if (difference == 2.5)
{
image.ImageUrl = "~/Images/Average.png";
}
else
{
image.ImageUrl = "~/Images/Good.png";
}
}
}
}
You may have to tweak it a bit since yours is an ASP.NET project - I don't have one loaded so my Image object doesn't have an ImageUrl property. It should make no real difference to execution speed (as the comiler will optimse it for the release version) but it does improve readability.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
i'm using SQL server analysis service 2000
and i want to process cube.
i tried to use "Microsoft.AnalysisServices"
but it return only
"A connection cannot be made. Ensure that the server is running."
but i can connect with Analysis Manager.
i tried to search and found "Microsoft.AnalysisServices.AdomdClient"
which execute with xmla.
it can connect to the database but it cannot execute command, there is a message said "The 'Command' parameter is of an unexpected type."
anyone, please please help!!
i dont know what i'm gonna do anymore...please T.T
|
|
|
|
|
What do you mean by "process cube"? (I may have an application that could help you, but I'm not sure exactly what you need.)
|
|
|
|
|
Hi,
I need some advice on the best way to go about this so I dont end up making it overly complicated.
I have a 2d graph draw in openGL the scale is set on drawing depending how much data there is.
What I need to do is make it interactive because at the moment with large ammount of data the finer point are lost because the scale is so big.
what would the best was to impliement a zoom feature so you can see part of the graph in more detail and move around the graph close up.
Im not the most advanced with openGL but any help would be great.
fyi this isnt for any collage or school work.
|
|
|
|
|
I want to set up a config section in my app.config that looks something like below:
<ConfiguredDatabases><br />
<Database Type="MyFirstDatabase" /><br />
<Database Type="MySecondDatabase" /><br />
<Database Type="MyThirdDatabase" /><br />
</ConfiguredDatabases>
But I don't understand how to the custom configuration class need to look like in order to get this to work. I found the below link:
http://devlicio.us/blogs/derik_whittaker/archive/2006/11/13/app-config-and-custom-configuration-sections.aspx[^]
But in that sample it looks like below:
<StartupFolders><br />
<Folders><br />
<add folderType="A" path="c:\foo" /><br />
<add folderType="B" path="C:\foo1" /><br />
</Folders><br />
</StartupFolders>
You see that there is a difference: The element names in the collection are named 'add'. I want the to have a custom name (like 'Database'). It's more clear to me. How would I proceed to achieve that?
Thanks for help!
|
|
|
|
|
Hi,
I want to know the first week num of Jan 2010 if first day of week is Monday. All day before monday should be considered under last week of previous year, i.e. As first monday comes on 4th Jan 2010, i.e. I am expecting Jan 1,2 & 3 under week 53 of last year.
I am using this code
System.Globalization.CultureInfo currentCulture = System.Globalization.CultureInfo.CurrentCulture;
System.Globalization.Calendar calendar = currentCulture.Calendar;
DateTime firstOfYear = new DateTime(DateTime.Now.Year, 1, 1);
int weekNo = calendar.GetWeekOfYear(firstOfYear, System.Globalization.CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday);
The week num is coming 52 instead of 53. What is going wrong? Is there any other way to do it?
Thanks.
modified on Thursday, January 7, 2010 10:19 AM
|
|
|
|
|
Change FirstFullWeek to FirstDay and you would get one. There is nothing like 53 week, AFAIK, so won't get that.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Thanks d@ninsh,
I think we can get that. Outlook calender displays that and that is what the help says for FirstFullWeek. If you use FirstFourDayWeek then it gives week 53 but i don't want to use because it will fail for me if new year week starts before wednesday.
|
|
|
|
|
If all you need to know is that first day is Monday or not, why not just check the DayOfWeek property for firstOfYear?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Thanks D@nish,
I am not trying to know about monday as first day. I am trying to extract the week num of first week where first day of week for me is Monday.
So, If the year (e.g. 2010) starts on Friday then Friday, Saturday & Sunday should be considered as days of last week of previous year and that is 53 for year 2009.I want this number(53).
Week number 1 should start from 4 Jan 2010 (Monday).
|
|
|
|
|
Oh. Once you get the day one first day of the month, you need to add/reduce the days to get to the first week accordingly. The tip posted in other reply would do that for you.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Week 1 of 2009 started on Monday, January 5th. This means that December 31st 2009, which fell on Thursday, was week 52. Thus Friday January 1st 2010 was also week 52; weeks start on Mondays, not Fridays - or any other days. (EDIT: I rush to add that weeks DO of course start on other days in many systems, but they did not in this case! Just in an attempt to preempt those who may already be writing to point out my cultural insensitivity.)
Thus you may *want* 53, but 52 is correct for 2010. The next time Jan 1st is in Week #53 is in 2013 (the last was in 2008).
modified on Friday, January 8, 2010 7:27 AM
|
|
|
|
|
d@nish wrote: There is nothing like 53 week, AFAIK, so won't get t
Oh yes there is! Week one of any year is the first week containing a Thursday in the new year. This means that Jan the first can be in week one, or in the last week of the previous year, which (depending on when Jan 1st was for that year) can be week 51, 52, or 53. There is an international standard for week of the year: ISO-8601[^]
[edit]Typos due to typing with gloves on - it's cold in here![/edit]
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
Yes, but since weeks have 7 days and 52*7 = 364 and a (leap) year has 365 (366) days, this means the first day of the year can be week 1, week 52, or week 53. For example, if a year starts on a Friday, there are only three days belonging to that week in the new year. Thus week 1 might start on the fourth day of the year, in which case we'd still not be finished with week 52 on December 31st. The only times you get to week 53 is thus - if the week start on Monday - when a year starts on Monday, or on a Tuesday AND it is a leap year.
For example, in a non-leap year that starts on Monday after 364 days or 52 full weeks it'll be Monday again but with one day to go; this will be Monday December 31st of whatever year it is, and the first day of week 53. The next day would then be January 1st, and since it's a Tuesday it clearly belongs to the same week as the Monday, since your weeks (as do mine) start on Monday.
|
|
|
|
|
|
Thanks Rich.
Actually, I wanted to display week num for starting days before monday of new year.
|
|
|
|
|
gajesh wrote: Actually, I wanted to display week num for starting days before monday of new year.
OK, that requires a little bit of mathematics - using my sample week 1 of 2009 starts on Monday, December 29, 2008, so add 52 * 7 (364) and we get December 28 2009, which is beginning of week 53, since we know that week 1 of 2010 begins on 4th January.
|
|
|
|
|
Thanks.
Yeah.. I'll do this calulation.
Thanks again.
|
|
|
|
|
If week one started December 29, 2009, I sure as heck wonder what week number you assign to the *previous* Monday, December 22, 2009.
In fact, there was a week 53 in 2008, so week 1 in 2009 didn't get started until Monday January 5th. Thus the last day of 2009 was still in Week 52 and so were the first few days of 2010. Week 52 is therefore correct, and the original question was flawed. Not that this isn't understandable - it's very easy to put a foot wrong on these things. The complexity is quite moderate, but very subtle!
(EDIT: By the way, I am fully aware that December 22, like December 29, did not fall on a Monday in 2009. The point is, and it's funny imo, there's been a rather humerously long week 53 or some unprecedented new all-time-high in week number if week one didn't get started until late December.)
|
|
|
|
|
I think you have got a bit confused, try re-reading my explanation.
|
|
|
|
|
Couldn't think of a decent subject. sorry.
If I add a DataGridView to a Form in constructor and create and set its datasource there itself. Now, I also check the rowcount in the constructor and it comes out as zero. Can someone explain the reason?
Here[^] is the question that triggered mine.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
I believe this is because the RowCount property is related to the rows visually represented by the DataGridView control. According to your steps, after the constructor has run you have a DataGridView control and a DataSource attached to it that is filled with data, but the DataGridView control hasn't done it's visual rendering yet. If you check the property after the DataGridView has been rendered and displayed at least one time, you should get the expected value. Try placing an event handler on the Form.Shown event and then put a break point in the handler and check the RowCount property.
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
|
|
|
|
|
That is what I had in mind as well. Let us see if we get a confirmation.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|