Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
string s={'a','b','c','d'}
how can i shown this string in gridview...using gridviewcontrol
Posted

Remove all the special char from the string and convert it into char array and bind the grid.
Try this:
C#
string s = "{ 'a', 'b', 'c', 'd' }";
string[] removeChar = { "{", "}", ",", "'" };
char [] GridData= s.Replace(",", "").Replace("{", "").Replace("}", "").Replace("'", "").Replace(" ", "").ToCharArray();
GridView1.DataSource = GridData;
GridView1.DataBind();



--Amit
 
Share this answer
 
Here is another way to split your string.

C#
string s = "{'a','b','c','d'}";
//Remove { } and ' characters and split the string.
string[] strGridData = s.Replace("{", "").Replace("}", "").Replace("'", "").Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

gridview1.DataSource = strGridData;
gridview1.DataBind();
 
Share this answer
 
Comments
Mohamed Mitwalli 31-Aug-12 16:09pm    
5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900