|
I have a problem in the following coding
protected void DataList1_ItemDataBound1(object sender, DataListItemEventArgs e)
{
DBCode dbo = new DBCode(); //class
DataTable dt = new DataTable();
dt = dbo.getDataTable("select IsSold, IsNew from product");
int a, b;
int c = int.Parse(dt.Rows.Count.ToString());
for (int i = 1; i <= c-1; i++)
{
a = int.Parse(dt.Rows[i]["Issold"].ToString());
b = int.Parse(dt.Rows[i]["IsNew"].ToString());
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (a == 1)
{
Label imgsold = e.Item.FindControl("lblsold") as Label; imgsold.Visible = true;
}
else
{
Label imgsold = e.Item.FindControl("lblsold") as Label; imgsold.Visible = false;
}
if (b == 1)
{
Label imgnew = e.Item.FindControl("lblnew") as Label; imgnew.Visible = true;
}
else
{
Label imgnew = e.Item.FindControl("lblnew") as Label; imgnew.Visible = false;
}
}
}
}
I want to enable and disable a label control with respect to the data coming from the database . this is actually a image gallery where i want make the image displayed with a tag new and sold . I have used datalist control and a two labels inside for displaying new and sold. but this code is not working so please help i am stuck in middle of the project
for further reference visit www.painternet.com/gallery.aspx
ram
|
|
|
|
|
Hey Ram,
clarify some things first.
what is ListItemType? is it a data list view?
also you can change int c = int.Parse(dt.Rows.Count.ToString()); to
int c = dt.Rows.Count cos the return type here is already int.
In the server, what datatypes are used for IsNew and IsSold?
What are the errors, if any?
He who goes for revenge must first dig two graves.
|
|
|
|
|
Hi
I want to use SQL View in my project. Is there any class in C# having functionality to produce SQL View.
Thanks
Atul
|
|
|
|
|
You use it just like a table, expect you can modify it.
|
|
|
|
|
Hello,
i'm developing at the moment a server-application, what can i do when my server has no performance anymore for this software? i could install it on a second server, thats right, but my problem is then to get variables, lists and other resources from the first server. how is something like that possible?
because big web-services for example google doesn't run on only one server too, so how can i make this that i can run one server-process per server but can access to the resources, lists and so on from the other servers?
|
|
|
|
|
1. Redesign your application/algorithm to run better.
2. Use remoting to communicate.
You will likely have to redesign most of the structure to support a distributed computing environment.
|
|
|
|
|
Well yes of course i could make my algorithm faster, but i have no idea which performance i need and so on, so i want to make it possible to use more server, now and not then when i see my server has no performance anymore
so how can i do this with the .net remoting, i've searched a little bit in the web but i can't find something really useful, has somebody a very simple example?
what does .net remoting? does it send easyly an object to another server?
|
|
|
|
|
Try google for distributed processing - its a very large and complex subject.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi,
I am running a .Net windows application on Vista platform. The code has some registry modification code. The code giving and access security exception if I am not expilictly running in administrator permission. Is there any way to run the application with the administrator permission by the code itself. Is that the CAS feature of the .Net framework?
please guide me.
|
|
|
|
|
|
Hello everyone,
As mentioned here,
http://msdn.microsoft.com/en-us/library/system.decimal(VS.80).aspx
"Conversions from Decimal to other types are narrowing conversions that round the Decimal value to the nearest integer value toward zero."
It conflicts my previous understanding that in all rounding in C#, we round to the nearest integer. Here is my test code. How strange it is, right?
using System;
class Test
{
static void Main()
{
Decimal b = 100.9M;
int a = (int)b;
Console.WriteLine(a);
return;
}
}
thanks in advance,
George
|
|
|
|
|
Well, it's doing what the docs say, so what's the problem ?
I guess the idea is that a Decimal is money, and if you have 100.9, you do not have 101.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Interesting answer, cool Christian!
regards,
George
|
|
|
|
|
George_George wrote: nearest integer value toward zero.
toward zero!
|
|
|
|
|
Could you say more words please?
regards,
George
|
|
|
|
|
It fits in with the general idea though - casting from a float/double to an int results in truncation and not rounding.
float f = 1.9f;
Console.WriteLine((int)f);
prints 1 and not 2.
|
|
|
|
|
Thanks Senthil!
From discussion with you, I found it is always truncated when convert from Decimal to other type?
Truncate means, 100.9 will result in 100.
Rounding means 100.9 will result in 101.
When rounding will happen? Previously I thought rounding will happen when do conversion, but from dicussion with you, when doing conversion, truncate other than rounding will be performned.
So, when there will be rounding?
regards,
George
|
|
|
|
|
George_George wrote: So, when there will be rounding?
When you call Math.Round[^].
|
|
|
|
|
Thanks Senthil,
So, could I make such a conclusion?
When conversion, always truncate? If yes, I am not 100% agree. A sample is, float a = 2F / 3F, when there is rounding 0.6666667, not truncating 0.6666666.
regards,
George
|
|
|
|
|
George_George wrote: If yes, I am not 100% agree. A sample is, float a = 2F / 3F, when there is rounding 0.6666667, not truncating 0.6666666
While there is no conversion involved in your expression, floating point arithmetic is a bit different. Take a look at http://www.codeproject.com/KB/dotnet/ExtremeFloatingPoint1.aspx[^]
|
|
|
|
|
Thanks Senthil!
In my sample 2F/3F, if it is not called as conversion, what is the correct terminology to call it?
regards,
George
|
|
|
|
|
I don't know the right word - the result of your expression exceeds the precision of a single precision floating point number. It's not overflow, as the range of float is much bigger.
|
|
|
|
|
Thanks Senthil,
In the article you referred, seems it is not mentioned the terminology for my sample, right?
regards,
George
|
|
|
|
|
Hi,
i am trying for WhiteBoard by connecting to remote machines using IP Address. I got source code for that. but when i run the code, i am unable to connect to the other machines... its giving error like "No connection could be made because the target machine actively refused it"
But the target machine dint receive any request to refuse... i am using the same Ip Address and port no which i have used for Audio & Video conference. There its working fine...
Below is the link for the source code...
http://www.codeproject.com/KB/dotnet/csharpwhiteboard.aspx?fid=4351&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=627213&fr=26[^]
Any help is appreciated....
Thanks in advance....
|
|
|
|
|
Firewall ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|