i have two forms, in one form i have three textboxes
and in another form i have one datagrid view control,
i want that the data i entered in textboxes will shown in datagridview control after i click on add button all the records will store in it may it is n number of record all n number of record will be shown in datagridview control but without creating database..
Is there any mechanism how to do this..????
Now say for example you have a button named Button1 and on the click even, you need to open Form2 and bind the textbox values to datagridview.
For this, first you have to create an object of Form1Class which will take these three textbox values into my object (here it is Form1Class). Once you created an object, you need to pass the object to Form2
Here, you have to think about data passing mechanism from one form to another form (Form1 to Form2).
There are many methods that we can pass data from one form to another.
1. You can use sessions, querystring etc...
For detailed view of how to pass data from one form to another form in asp.net , have a look at below links
In this case what you can do is create a custom data table in the form, having three columns as the three text box,
Once you have this structure in place you can create a data row and append it to the table and set the datatable as the data source of the gridview.
let me know if you have any question.
I have a random class (determined at runtime)... this class constructor may or may not have parameters (determined via a lookup table). I need to new up said class as fast as humanly possible. So I went with expression trees. Since I don't know how many parameters the constructor will have (until I'm building the expression tree), my concept is to get the parameters into an object and then type cast o, o, o, etc. to the proper types. The expression comes out as:
So I'm getting a Func<object, object>... seems kind of slow (relatively) to be honest... is compiling it to a lambda causing overhead? or is there some other overhead I'm not seeing? Since the params can be any type, I don't know how I could store them in anything else other then an object. Seems like I might be generating a method vs. doing it inline?
Any ideas? This code is called *a lot*, so every ms counts .
I'm caching the Func<object, object>'s in a dictionary. Just seems slower then doing a normal new up for the same # of iterations and I was under the impression its supposed to be just about the same performance. I realize my code has other overhead, of course, but still...
Seems like it might have something to do with the parameters. Right now the constructor for the test class is:
public Test(string str, int i, Color color)
and new'ing up 1M takes 475ms with my current code. By doing NOTHING but changing the constructor to just:
public Test(/*string str, int i, Color color*/)
it drops to 200ms. So I tried adding 1 param back and it jumps to 312ms. 2 params = 390ms.
So... every additional param is adding quite a bit of time .
Now, adding back the first param was +112ms, but the 2nd one was only an additional +78ms. I would expect adding back the first param would be expensive since it would now travel down the param code path where without params it skips all that. However, I expected adding the 2nd param would be much cheaper since its just adding another iteration to the param loop.
A standard new up with all 3 params for 1M iterations takes only 31ms.
I'm estimating that there is about 140ms of overhead built into my dynamic new up code, I'm just not getting why adding params is so expensive. So I tried one more test...
for (int i = 0; i < 1000000; i++)
int j = 5;
string s = "hello";
Color cr = Color.Red;
//int k = j;
//object k1 = j;
//object k2 = s;
object k3 = cr;
Seems like the boxing & type casting of the int and color is killing the performance. Boxing a string seems to be pretty cheap. The int and color are structs though...
The requirements are to create objects on the fly with any number of constructor arguments. Almost like DI, but with a different spin. The only way I thought of being able to do that is to create an object as an input parameter and pass the arguments to the constructor as array, array, array and type casting to the proper type (from ConstructorInfo and ParameterInfo). Hmm... I added support for making constructor params byref, but that didn't help. Also doesn't seem to make a big performance diff if I pass in classes.
Lets say I have a solution (A) or a project (A) which is working properly and its framework is 2.0.
And I have a seperate empty project(B) which is I set its framework to 3.5. When I add my working project(A) to that blank solution what will be my working project's solution? Is it going to be updated to 3.5 automatically from 2.0 to 3.5?
If not, changing project (B)'s(-where project (A) is already been added to project (B) ) framework manually from the solution's property window to 4.0 also changes project (A)'s framework as well(will .Net automatically change that project framework)?
Target framework is a project property and not solution property. It's possible that a solution has different projects with different target framework.
If you have a working project with specific framework and you do not mean to change/extend functionality - do not change target framework...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
I think certain kinds of "advice" without reference to the actual documentation is worthless (as in this case).
If one consults the actual documentation (help) re: "Data Contracts" it notes that:
"All .NET Framework primitive types, such as integers and strings, as well as certain types treated as primitives, such as DateTime and XmlElement, can be serialized with no other preparation and are considered as having default data contracts."
"New complex types that you create must have a data contract defined for them to be serializable."
I would say that your "Members" property is NOT a "primitive" type and therefore must have a "data contract".
(The SO example conveniently only shows primitive types).