Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how i can split records in gridview with checkbox from database?
547283,546748,545497,545106,543740 i have stored given numbers are single row in sql but i have display that numbers are in gridview as 5 rows with checkbox how is it? send ans to this mail id friends [emails removed]
Posted
Updated 21-Mar-13 21:17pm
v2
Comments
Maciej Los 22-Mar-13 3:18am    
It's not working like that. You ask, we answer. No emails!
Maciej Los 22-Mar-13 3:19am    
What have you done till now???
Why single row?

Try below to split your string containing numbers separated by comma(,) operator.
C#
string s = "547283,546748,545497,545106,543740"; // Your string
string[] values = s.Split(','); // splitting string based on (,) operator..

//split values are below..
//string[0] contains 547283
//string[1] contains 546748
//......
//...
//.

Now bind gridview rows using these values..
 
Share this answer
 
Hi,

Please try below code.



C#
protected void Page_Load(object sender, EventArgs e)
       {
           string s = "547283,546748,545497,545106,543740"; // Your string
           string[] values = s.Split(','); // splitting string based on (,) operator..


           GridView1.Columns.Add(new TemplateField());
           BoundField a = new BoundField();
           GridView1.Columns.Add(a);


           GridView1.DataSource = values;
           GridView1.DataBind();
      }



C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType != DataControlRowType.Header)
            {
                e.Row.Cells[0].Controls.Add(new CheckBox());
            }
        }
 
Share this answer
 

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