|
Thank You
Allan F. Gagnon
|
|
|
|
|
hello All,
The template field in gridview has a html table which is binded to datasource from sql server all the data is displayed fine my question is, is it possible to display the data in two columns instead of one column, if Yes how is it done. Please see below for code, Any suggestions are appreciated.
<itemtemplate>
" width="100" height="100" border="0"> | | $<%# Eval("Price") %> | | <%# Eval("ProductName") %> | |
Thanks in Advance for your help. Best Regards
|
|
|
|
|
Hi,
I have two projects in VS2005 that seem to run differently and I don't know why?
Psuedo code situation:
Windows Form - On_Load
read database
set radiobutton.checked = true/false depending on value in database field.
Windows Form - click radiobutton event
change to true/false in database.
The problem I am having is that in one project the click event is not being fired on loading but in the other it is fired. I don't want the click event fired at loading.
I have spent hours on this and am no closer to resolving the issue
Any suggestions on where to look for the difference in the two programs will be appreciated.
Glen Harvy
|
|
|
|
|
Hi,
the question is not clear yet. What click event ? or do you mean a CheckedChanged event?
I suggest you give your programs a name, and probably show some relevant code for each.
Luc Pattyn
|
|
|
|
|
For given array of objects, I need to produce a another list or two-dimensional resulting array or something where each pair of values consists of a one unique element from the original array and the number of times that element appears in original array.
Tried google, but as usual... of about 100 results none is even close to what I need.
I know this is trivial... but again... I'm trying it for 3 hours and no solution...
|
|
|
|
|
Hi,
you could create an empty hash table and enumerate your collection:
- use your item as a key
- first test if the key already exists in the hash table
- if not, add a (key,value) pair with value=1
- if yes, modify the entry with that key to become (key, old value + 1)
Et voila.
Luc Pattyn
|
|
|
|
|
Great, got some solution on my own finally... though this sound better... I'll post mine in a so you can laugh bit...
but it does work...
<code> class Program
{
static void Main(string[] args)
{
ArrayList ResultList = new ArrayList();
int[] repeatCount = new int[5];
object[] originalObjectArray = new object[5];
Console.WriteLine("Enter array");
for (int i = 0; i < 5; i++)
originalObjectArray[i] = Console.ReadLine();
ResultList.Add(originalObjectArray[0]);
repeatCount[0] = 1;
int passCount = 0;
foreach (object o in originalObjectArray)
{
if (passCount > 0)
{
bool upis = true;
for (int i = 0; i < ResultList.Count; i++)
{
if (ResultList[i].Equals(o))
{
repeatCount[i] += 1;
upis = false;
}
}
if (upis == true)
{
ResultList.Add(o);
repeatCount[ResultList.Count - 1] = 1;
}
}
passCount++;
}
for (int l = 0; l <ResultList.Count; l++)
Console.WriteLine("Broj ponavljanja elemnta " + ResultList[l].ToString()
+ " je " +repeatCount[l].ToString());
}</code>
BTW how do I test if key is already in Hashtable?
|
|
|
|
|
Hi,
I did not laugh, but I was amazed about the complexity you introduced.
Will you ever feel sure this is correct ??
Some detailed remarks:
1) your code can handle no more than 5 objects, there is no need for such a limitation
2) I did not like the name "o" for one of the objects; I avoid single-character names
except maybe for local int counters; for real objects, I use real names.
3) you did the first object outside the for loop, then needed extra stuff
(passcount>0) to skip it inside the loop; better do everything inside the loop
But in the end, you followed the approach I suggested.
Did you realize you are relying on the fact that ArrayList preserves the order
of the elements added (unless you instruct it otherwise, e.g. Sort) ?
When using a hashtable, you dont need such assumption: it is intended to keep
key,value pairs together (as opposed to your code trying to keep an ArrayList and
an int array in the same order).
The test you need is Hashtable.Contains()
May I suggest you take some time to read up on collections (mainly ArrayList
and Hashtable). They are powerful tools that can be applied on many occasions,
requiring less code (and hence offering less room for bugs).
Regards.
Luc Pattyn
|
|
|
|
|
I was aware I can only take 5 elements... indeed it was only prototype I built before you gave me idea I should use hashtable... regular usage of this wouldn't be user input 5 strings from console... nor it should be in main at first place... it should be method... probably in separate class that is given array as argument... and it return (Hashtable) which contain unique elements and their count...
My first try before Hashtable was actually 2 dimensional object array... but was tired of casting int in and out for count every time... so I switched to int array+arraylist... don't know which solution is more complex. I'll redo my code now with hash table...
I know about conventions to never give single letter variable names... didn't do it on purpose... and would certainly rename this later if I was happy with approach... I already had bunch of commented code so it was mess... I always first comment things out I don't like... then move them beyond last } and only delete them after I have final release fully debugged...
Sure I got some good read on generics so I hope that will give me some idea...
Thanks guys for help, this was actually one of questions I had to solve on my job interview-test yesterday... other questions were more like this... combined with ADO.NET, few SQL only... and some .Net stuff.... like, what is base class in net... and such stuff...
I messed up this one that is sure...
|
|
|
|
|
I like generics.
Dictionary<string, int> words = new Dictionary<string, int>();
string word;
while ((word = Console.ReadLine()).Length > 0) {
if (words.ContainsKey(word) {
words[word] = words[word] + 1;
} else {
words.Add(word, 1);
}
}
foreach (KeyValuePair<string, int> pair in words) {
Console.WriteLine(pair.Key + " : " + pair.Value.ToString());
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Got it...
public Dictionary<object, int=""> GetUniqueElementCollection(object[] PassedArray)
{
Dictionary<object, int=""> ResultList = new Dictionary<object, int="">();
foreach (object origObject in PassedArray)
{
bool exist = false;
foreach (KeyValuePair<object, int=""> obj in ResultList)
{
if (obj.Key.Equals(origObject)) exist = true;
}
if (exist)
{
ResultList[origObject] += 1;
}
else
{
ResultList.Add(origObject, 1);
}
}
return ResultList;
}
what do you think guys?
|
|
|
|
|
i have created my first game a simple puzzle system, and I'm not an all star with programming yet, i would like to run a a short video when the program is opened, preferably a flash file but its not a major issue if its not, also i don't want this file to run inside a media player such as WMP or Itunes. is this possible and if so any ideas on how to achieve it.
|
|
|
|
|
hi all,
I am a newbie in serial communication program.I have done a small program that can send request and get result from third party device.What i am doing is using do-while to try get data from serialport and using timer to do ReadTimeOut function.Then,if fail to get at the first time,i will retry to get another time.
Now i would like to try using SerialDataReceivedEventHandler (i dun know whether using SerialDataReceivedEventHandler is better than using do-while loop or not)to replace my existing program.I know i can use serialport control.But i am confusing to use it and dun know how to implement it just like my existing program.
Any hits or guides are welcome.
thanks in advance.
regards
cocoonwls
|
|
|
|
|
Dear all,
I'm looking for advice how to create a report. I want to dynamically create an invoice preferably in Word or a PDF. I can find heaps and heaps of code on how to export datagrid's to Excel in VB.NET or ASP.NET , but that is not what I'm after.
I have a datagrid, and I want to export the datagrid to either a word document ( so I can print it later ) or export it to another form and build a report that way.
Can anyone point me in the right direction ?
Cheers,
|
|
|
|
|
hi,
You may try Reportviewer.I am just start to use this tools also ,it seem nice.Just drag it into panel and create a report using report viewer task.Hope this help you
cocoonwls
|
|
|
|
|
Hi guys,
I have a class named Configuration which is basically a collection of configItems.
Each config item has the following:
ID (allows persisting to file/database)
Name (a friendly way of searching for the item)
Value (self explanatory)
At present, ID is an integer type and both Name and Value members are string types.
However, the value may actually represent a boolean, integer, string, decimal and potentially other types.
The annoyance is currently having to cast the value to and from string to whaterver object type is required.
It would be great if the Value member could be the correct object type without having to cast each time.
I guess being able to have a generic member would be ideal but from my knowledge of generics, this doesn't appear possible.
How do you guys approach situations like this? What would you do?
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
You could create a base class that contains just Id and Name, and create subclasses for each data type.
The base class could contain methods for getting data from each subclass. For example:
public int GetInt32() {
ConfigurationItemInt32 item = this as ConfigurationItemInt32;
if (item == null) {
throw new ApplicationException("Item is not an Int32 value.");
}
return item.Value;
}
---
single minded; short sighted; long gone;
|
|
|
|
|
I am writing to find out how I can escape special characters such as the (') when submitting information into a db using sql. The (') is causing my sql statement to break. Is there some kind of string function to search for these character's in a string and replace them? Please advise. Thanks.
|
|
|
|
|
You should be using paramatized queries and not directly using or concatenating user input to create a query otherwise your database is open to an sql injection attack.
You may find this article usefull:
http://www.codeproject.com/cs/database/SqlInjectionAttacks.asp
Hope this helps
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Not sure you're in the right forum - however replacing (') with ('') should work for you. ('') is the single quote twice not the double quote.
|
|
|
|
|
parsing dicom image file to bmp ?
dicom file is a encrpted file which has pixel data aswell as patient data
rajesh
-- modified at 15:18 Wednesday 14th February, 2007
|
|
|
|
|
You are going to have to ask better than that. At least give people enough information so they could be able to attempt to help you.
|
|
|
|
|
Hi,
i'm new developer in C#.. how create a Folder in C# language?
Thanks..
|
|
|
|
|
Use the Directory.CreateDirectory method.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
See: http://msdn2.microsoft.com/en-us/library/system.io.directory_members.aspx
Directory.CreateDirectory(INSERT_FOLDER_NAME_HERE);
Enjoy!
|
|
|
|