|
Hello everyone,
I failed to find a sample about how to convert an array instances of user defined types into a (C# ADO.Net) datatable -- I want to use the datatable to bind to ASP.Net data bound controls (e.g. gridview). Could anyone provide a sample or recommend me to some simple samples?
Another question is, whether it is a must to convert to datatable in order to bound to controls in ASP.Net? Could I bound to any array of user defined types?
thanks in advance,
George
|
|
|
|
|
George_George wrote: I failed to find a sample about how to convert an array instances of user defined types into a (C# ADO.Net) datatable
Loop through the array and add items to datatable.
George_George wrote: whether it is a must to convert to datatable in order to bound to controls in ASP.Net?
Nope. Datasource can be any type which is enumerable. And yes, arrays are enumerable.
|
|
|
|
|
given input: DNo:12,Crystal Building,ghn O M R Road;5 e c r road; c/o r v rao
reversing the string: oar v r o/c ;daor r c e 5;daoR R M O nhg,gnidliuB latsyrC,21:oND
the reverse input string is passed to REGEX pattern
string str1 = Regex.Replace(g, @"(?<=^|,|;|#|&|.)([^0-9]) (?=[^0-9](?:=| |;|#|&|,|#|$))", "$1");
obtained output after reversing: DNo:12,Crystal Building,ghn OMRRoad;5 ecrroad; c/o rvrao
required output is: DNo:12,Crystal Building,ghn OMR Road;5 ecr road; c/o rv rao
anybody can fix this simple error..
thank you
the quieter u become more u hear
|
|
|
|
|
That's what I was asking for. A real example of what you were actually trying to do instead of a lot of made up examples that didn't resemble any real data.
(?<= )(\w) (?=\w )
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
that didnt work out...
what i need is
1. it should merge only single characters
2. but should not merge numeric values. only alphabets should be merged
3. also should stop if delimers are found (!@#$&')
can you help me
the quieter u become more u hear
|
|
|
|
|
Ok, do you have any example where it doesn't work? This is the output you required:
DNo:12,Crystal Building,ghn OMR Road;5 ecr road; c/o rv rao
And this is the output that I got (copied straight from the console):
DNo:12,Crystal Building,ghn OMR Road;5 ecr road; c/o rv rao
That looks pretty identical to me...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
this example doesnt work out
DNo:12,Crystal Building,ghn O M R Road;5 e c r road; c/o r v rao
if found the solution kindly send me the pattern which you are using
the quieter u become more u hear
|
|
|
|
|
That's exactly the input that I was using. It's working just fine, and I already posted the pattern that I was using.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
"DNo:12,Crystal Building,ghn O M R Road; 5 e c r road; c/o r g rao";
that bold part alone has errors it shows 5ecr...
i told you numeric values should not be included even if it is single... could u fix it out
thanks for your help
the quieter u become more u hear
|
|
|
|
|
lawrenceinba wrote: that bold part alone has errors it shows 5ecr...
No, it doesn't. Look at the output that I posted.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
please try this input
"DNo:12,Crystal Building, behind O M R Road; 5 e c r road; c/o r g rao"
the output merges 5ecr
the quieter u become more u hear
|
|
|
|
|
great conversation, keep it up!
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Yes, that does give a different output. Use this pattern:
(?<= )([A-Za-z]) (?=[A-Za-z] )
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
before rebuild my project its work properly But if rebuild it then gives error for each form.
The error is -
Unable to copy file "obj\Debug\Hospital.frmAddMedicine.resources" to "obj\Debug\Hospital.obj.Debug.Hospital.frmAddMedicine.resources". Could not find file 'obj\Debug\Hospital.frmAddMedicine.resources'. Hospital
But before rebuild the project all the resource file was present. Please help me.
|
|
|
|
|
Clean then rebuild.
maybe you have a couple of files' attributes set to read-only.
you can get rid of the obj folder each time you rebuild, no worry.
|
|
|
|
|
I am developing an sms application, whenever the application receive an sms it is assigned to a string. the string value is something like this:
+CMT:"+658208342",,"09/02/08",16:15:22+50"<br />
Test Message from coder
String text = (above code lines)
i have to take the Mobile number, datetime , and text as 3 different string from the above string.
Now what i had is that i use split whenever a string have " and then add it to an array
string s = text.Replace(",,", "");
string[] values = s.Split(new char[] { '"' });
string incoming_msg_number = values[1];
Thread.Sleep(50);
string msg_date_time = values[3];
Thread.Sleep(50);
string msg_text = values[4].Trim();
MessageBox.Show("Number :" + incoming_msg_number + " \r\nDate & Time: " + msg_date_time +
"\r\nMessage :" + msg_text);*
It DIDNT work because there are chances of quaotes within the incoming message
Will regex can do something with this?? if so how??
thanks....
|
|
|
|
|
Aghosh Babu wrote: +CMT:"+658208342",,"09/02/08",16:15:22+50"
Test Message from coder
Are they on two separate lines? In other words, is that an '\n' character I see within the string?
I are troll
|
|
|
|
|
|
+CMT:"+658208342",,"09/02/08",16:15:22+50"
Test "Message" from coder
So, this would fail, since there are quotes on the second line?
Would it help if you split the string based on the NewLine first? Something like this;
string[] Message = s.Split('\n');
This will put the first line in Message[0], and the text-message in Message[1]. You can then safely split your values on the quotes like;
string[] values = Message[0].Split(new char[] { '"' });
HTH
I are troll
|
|
|
|
|
hi thanks, but i cant split with quotes because the incoming SMS may contain quotes too...! any other method other than split??
|
|
|
|
|
The incoming SMS will contain quotes on the second line? If so, there shouldn't be any problem splitting them once you have separated the first and the second line? In other words, Split only on "line 1", without touching line 2:
+CMT:
+658208342
09/02/08
,16:15:22+50
and
Test "Message' from coder
There are lots of methods to manipulate strings, including, but not limited to, regular expressions, the internal string-routines (Substring, IndexOfAny), parsers..
I are troll
|
|
|
|
|
|
I would use a Regular Expression to split the string. Is it always two lines per message? Or sometimes more?
This
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex
(
"(?'A'[^:]*):\"(?'B'[^\"]*)\",,\"(?'C'[^\"]*)\",(?'D'[^\"]*)\"\n(?'E'[^\n]*)\n"
,
System.Text.RegularExpressions.RegexOptions.Compiled |
System.Text.RegularExpressions.RegexOptions.Singleline |
System.Text.RegularExpressions.RegexOptions.CultureInvariant
) ;
is giving me:
A >+CMT<
B >+658208342<
C >09/02/08<
D >16:15:22+50<
E >Test Message from coder<
Did you leave out a quote in your data?
modified on Sunday, February 8, 2009 9:21 AM
|
|
|
|
|
its always 2 lines. is the A,B,C,D,E strings ? can i call these strings later within the method?? Thanks alott. .
|
|
|
|