Sunday, March 31, 2013

Convert a Comma Delimited String to an ArrayList in C#


In the previous post i had shown u how to Convert comma delimited string to Dictionary
Now i will show how to Convert comma delimited string to string array, is easy as shown below...



string Val = "a,b,c,d,e";

string[] myStringArray = Val.Split(',');


in the  same way converting comma delimited string to arraylist is also easy in a single line as shown below....

//Method1
ArrayList myArrayList = new ArrayList();
myArrayList.AddRange(Val.Split(','));



//Method 2
ArrayList list = new ArrayList(Val.Split(','));
 
 
Out Put :


myArrayList[0] = a;
myArrayList[1] = b;
myArrayList[2] = c; 
myArrayList[3] = d;
myArrayList[4] = e;

Convert a Comma Delimited String to an Dictionary in C#

Here i will show how to Convert a Comma Delimited String to an Dictionary in C#
In the previous post i had shown u how to get all selected values from ListBox
continuing the above link.....



string Val = "a,b,c,d,e";

Dictionary<string, string> MyDict1 = new Dictionary<string, string>();

MyDict1 = Val.Split(',').ToDictionary(key => key.Trim(), value => value.Trim());

Out Put :

a -> a
b -> b
c -> c
d -> d
e -> e 

Colspan in Jquery DataTables using C# in asp.net GridView

In this post i will show how to Make Colspan for Jquery DataTables in ASP.Net GridView.

Actually ColSpan is not supported in Jquery DataTables

Previous Posts :

So here is a small trick to do it in server side....


OutPut :


















Friday, March 29, 2013

Get All selected values from listbox in asp.net OR how to get listbox value codebehind multiple value in asp.net

Here i will show how to get all selected values from ListBox in asp.net

Out Put :






ASPX.Net :


Converting Numbers to Words in C# (OR ) how to convert number into words in C#

In this post i will show how to convert numbers (integers, decimals) to words as shown below.

EX :   1008  ==> Indian Currency : One Thousand Eight Rupee(s) And Zero Paise Only.
                             Dollars : One Thousand Eight Dollars(s) And Zero Cents Only.

Out Put : 



 ASPX.Net :

Show line number in exception handling using C#

Here i will show how to display Exception Line Number in C#.Net as shown below......
The Exception in this Out is due to SQL Connection....
  1. First create a class called ExceptionHelper.cs 
  2. Write a  public static method as shown below..........
Out Put :





C# Code :