|
What about the Key feild of both xml file. both are same or what ?
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I'm very new to C# and .NET and this is my very first project. I have a form that allows people to enter quantity of the item they order and then displays the description and quantity of the selected items. I'd like to capture the values from a list of textboxes and pass them to an array and have no idea how to start. Please help. Thanks
|
|
|
|
|
One way to do it is as follows:
<br />
using System.Collections;<br />
...<br />
<br />
private ArrayList MyArray = new ArrayList();<br />
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
MyArray.Add(this.textBox1.Text);<br />
}<br />
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Yes, I've done that. The only problem is I have to pass multiple textboxes values. The textboxes were name as txtBox1, txtBox2 ... and so on. I guess I'm having problem with passing those names as variables. Any helps would be appreciated. Thanks
|
|
|
|
|
If you can provide some code, I can help you more. I don't think I really understand what you want to achieve. If you are using multiple textboxes you can do the following:
<br />
...<br />
MyArray.Add(this.txtBox1.Text);<br />
MyArray.Add(this.txtBox2.Text);<br />
MyArray.Add(this.txtBox3.Text);<br />
...<br />
or you may want to use multi-dimensional arrays... Just submit some code so I can help...
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Thanks Radgar. I was able to load ALL the items to a datagrid. However, I only want to display only items that have values on the quantity boxes.
Here it is, with Merchandise is a class that loads the textboxes and hidden fields to the array.
---------------------------------------------------------------
private void Submit_Click(object sender, System.EventArgs e)
{
ArrayList ListItems = new ArrayList();
ListItems.Add(new Merchandise(txtQty1.Text, hdnDesc1.Value));
ListItems.Add(new Merchandise(txtQty2.Text, hdnDesc2.Value));
ListItems.Add(new Merchandise(txtQty3.Text, hdnDesc3.Value));
ListItems.Add(new Merchandise(txtQty4.Text, hdnDesc4.Value));
DataGrid1.DataSource = ListItems;
DataGrid1.DataBind();
}
---------------------------------------------------------------
I'm thinking of 2 dimentional array as well but still struggling on how to implement it since I'm very new at this. Thanks again Radgar
|
|
|
|
|
If I understood right, you don't need ArrayLists here. I think the following solution will solve your problem. Let me know if it does.
<br />
DataSet myDataSet = new DataSet("myDataSet");<br />
DataTable myTable = new DataTable("Merchandise");<br />
myTable.Columns.Add("Param1");<br />
myTable.Columns.Add("Param2");<br />
<br />
DataRow myRow;<br />
myRow = myTable.NewRow();<br />
myRow["Param1"] = "some value";<br />
myRow["Param2"] = "some other value";<br />
myTable.Rows.Add(myRow);<br />
myDataSet.Tables.Add(myTable);<br />
<br />
myTable.DefaultView.RowFilter = "Param1 <> ''";<br />
<br />
dataGrid1.SetDataBinding(myDataSet, "Merchandise");<br />
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
I used the ArrayLists and it worked. However, I used your logic for another form on the application and was successful. Thanks again for your help and patience Radgar.
|
|
|
|
|
Glad to hear that.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
I am new to progamming world and just want to start with C#.
How can I write a simple program like
The program will ask u
what is your name?
You type:
Robert
and it say
Hi, Robert.
Thank so much.
|
|
|
|
|
The Console class has what you are looking for. Look for the ReadLine() and the WriteLine() methods.
Regards
Senthil
My Blog
|
|
|
|
|
Anonymous wrote:
The program will ask u
what is your name?
Console.WriteLine("what is your name?");
Anonymous wrote:
and it say
Hi, .....
Console.WriteLine("Hi, " + Console.ReadLine());
|
|
|
|
|
I want to save a great float type data array into a SQL server database. But I donot know how to convert a float array (float[]) to a byte array (byte[]) . Please help if anyone can solve this problem, thanks .
xu guoqing
|
|
|
|
|
The BitConverter class does the job. You can do somthing like
<br />
byte[] GetByteArray(float []f)<br />
{<br />
byte[] byteArray = new byte[f.Length * 4];
int index = 0;<br />
foreach(float floatVal in f)<br />
{<br />
byte []convertedBytes = BitConverter.GetBytes(f);<br />
byteArray[index++] = convertedBytes[0];<br />
byteArray[index++] = convertedBytes[1];<br />
byteArray[index++] = convertedBytes[2];<br />
byteArray[index++] = convertedBytes[3];<br />
}<br />
<br />
return byteArray;<br />
}<br />
Does this help?
Regards
Senthil
My Blog
|
|
|
|
|
How can get the codeDOM tree of a method at runtime? Something like this:
((CodeMemberMethod)RetrieveCode(someObject.GetType().GetMethod("MyMethod"))).Statements;
Greetings Harald
|
|
|
|
|
What you are trying to do is logically not possible, unless there is some intermediate file that maps IL to language statements. You see, once you compile the code, the source is gone, it may not even exist on the machine the code is being run. Even if it does, there is no association (except for map files) between the IL and the source.
Regards
Senthil
My Blog
|
|
|
|
|
Your Wrote :
see, once you compile the code, the source is gone,
Where ? Can you explain it little bit more ?
Sreejith Nair
[ My Articles ]
|
|
|
|
|
What the (@^^% do you mean 'where'? No-where! It's forgotten about! Once the source IL is compiled, it isn't needed anymore, so it gets dropped.
What do you think happens when you call .Clear() on a TextBox? Where does that data go?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You wrote:
(@^^%
I love to answer for this. but if i do , then what is the difference.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
There is at least a very pedestrian method: I can, probably, access the source code and create the code DOM tree out of it and so on. My question is: Is there a more elgant way, possibly without the need to deliver some textual things.
Harald
|
|
|
|
|
Oh, you're planning to ship your source too?
Regards
Senthil
My Blog
|
|
|
|
|
Right then, how do i encrypt something so that when you click on it instead of windows going 'im an idiot what do i open it with?' (or something like that), do i get it to display a message box, saying something like, 'Stay away from my stuff'.?
Or is this just asking to much?
Any help would be much apreciated. Thanks
|
|
|
|
|
|
People could change thefile association but, smart thinking there, hmm, how do i get the file exension to be associated with the app, without having to do it myself (right-click, open with, etc.)?
|
|
|
|
|
You can add a few keys to the registry:
Under HKCR add a key with the name of your extension, for example ".mef" (my encrypted file).
Add a subkey "Shell", a sub-subkey "Open" and a sub-sub-subkey "Command".
Set the standard value of the new "Command" key to the program you want to execute, for example "notepad %1".
So now you should have:
HKCR
+--.mef
+--Shell
+--Open
+--Command (Standard) "notepad %1"
Explorer will show the icon of the application (notepad in our example) and open notepad when you doubleclick a .mef file.
mav
|
|
|
|