Reflection, reflection, reflection... cycle through the objects and compare the object names against your string.
echuck66
Posts
-
how to created object referenced by a string -
How to copy data table to arraylist ...?Why not create separate DataRow arrays for each expression if you want to segregate them, or use OR in your select string if you want to group them all together? For example (using expresion segregation): DataTable dt = ...(your data table definition) DataRow[] drMobile = dt.Select("ItemName = 'mobile'"); DataRow[] drTV = dt.Select("ItemName = 'tv'"); DataRow[] drRadio = dt.Select("ItemName = 'radio'"); DataRow[] drComputer = dt.Select("ItemName = 'computer'"); or (grouping them all together): DataTable dt = ...(your data table definition) DataRow[] drows = dt.Select("ItemName = 'mobile' OR ItemName = 'tv' OR ItemName = 'radio' OR ItemName = 'computer'"); By the way, I don't recommend using ArrayList... instead, use Generics, for example, instead of using: ArrayList al = new ArrayList(); string v1 = "some text"; string v2 = "some more text"; string v3 = "even more text"; // you get the point... al.Add(v1); al.Add(v2); al.Add(v3); // etc. and then casting the content back to a string variable: string v1Str = (string)al[0]; ... Use Generics: List<string> al = new List<string>(); string v1 = "some text"; string v2 = "some more text"; string v3 = "even more text"; al.Add(v1); al.Add(v2); al.Add(v3); // etc. now, you don't have to cast the values back to a string when you retrieve them: string v1Str = al[0]; string v2Str = al[1]; ... Depending on what you are storing in the ArrayList, the cast operation can be very costly in terms of performance. Microsoft doesn't recommend using the ArrayList in .NET 2.0 and higher. -- modified at 22:03 Sunday 18th November, 2007
-
What would be the proper way to comment within this code?using // or /* */...
-
Erro wen sql server table has a empty valueFor simple select statements such as this, I would use ISNULL in the sql command... For example, using the code you included: SqlCommand comm00 = new SqlCommand(); string commSQL = "SELECT ISNULL(Cmp_nr, '') AS Cmp_nr FROM Companies where Cmp_name=@cmpName"; SqlPararameter cmpParam = new SqlParameter("@cmpName", SqlDbType.VarChar, 50); //note: 50 should be changed to the field length of your db field Cmp_name cmpParam.Value = companyName; comm00.Parameters.Add(cmpParam); comm00.Connection = myconn; comm00.CommandText = commSQL;
-
What is the weirdest item you have in your box of spare parts?Microsoft OS/2 Version 1.0... from an old voicemail system.
-
How Can i Show a PDF File in an Iframe of my form?I'm not sure about the IFrame part, but if you want to embed a PDF in a web page, you might want to check this out: http://www.codeproject.com/aspnet/EmbedPDFinWebpages.asp[^]
-
help for Remember Passwordthis is not very secure... if you put a flag in the database to check for password if not checked, then anyone who puts that user's username in will have full access. you need to identify the specific user with a user account. This is usually accomplished by using a persistent session or cookie.
-
help for Remember Passwordyou might want to check out the authentication features of .NET 2.0 www.asp.net has some great video tutorials on how to implement this. This is usually accomplished through the use of cookies or sessions.