aadi patel

aadi patel

  • NA
  • 53
  • 33.4k

Twodimensional arraylist using split function in gridview

Feb 27 2013 5:10 AM

I have two string containing list of ids and respective values.

I want to add them in gridview like we have table with id and proper value.

I have already try this for only "id" below code is for only "id"

    string id = "1,2,3,4,5";

ArrayList list = new ArrayList();

list.AddRange(id.Split(new char[] { ',' }));

GridView1.DataSource = list;

GridView1.DataBind();

we have one column and five rows in gridview on execution of this code.

but i need two columns having id and values. how can we do this ?

    string id = "1,2,3,4,5";

string value = "abc,pqr,xyz,mno,qwe";

ArrayList list = new ArrayList();

list.AddRange(id.Split(new char[] { ',' }));

list.AddRange(value.Split(new char[] { ',' }));

GridView1.DataSource = list;

GridView1.DataBind();

this give me single column having 10 rows instead of this i want two columns each i have respective id and values.


Answers (1)