Please, read my comment to the question first. As i mentioned, you have to keep your focus on data, not gridview object.
On the first look you have 2 ways to achieve that:
#1
Split data on server side by using
CTE[
^] or
custom function[
^].
split string from database column and display in gridview[
^]
get 2nd and 3rd string by splitting a long string using T-Sql[
^]
#2
Split data on client side by using dataset (datatable) and Linq
LINQ Tutorial - Linq to strings with examples.[
^]
Take a look at example:
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("No", typeof(int)));
dt.Columns.Add(new DataColumn("Code", typeof(string)));
dt.Columns.Add(new DataColumn("qty", typeof(string)));
dt.Rows.Add(new object[]{1055, "956,957,958,959", "10,9,5,4"});
var result = dt.AsEnumerable()
.Select(x=>new
{
No = x.Field<int>("No"),
Codes = x.Field<string>("Code")
.Split(new string[]{","}, StringSplitOptions.RemoveEmptyEntries)
.Select((a, b) => new
{
Index = b,
Code = a
}),
Qty = x.Field<string>("qty")
})
.Select(x=>new
{
No = x.No,
Code1 = x.Codes.Where(y=>y.Index==0).Select(z=>z.Code).SingleOrDefault(),
Code2 = x.Codes.Where(y=>y.Index==1).Select(z=>z.Code).SingleOrDefault(),
Code3 = x.Codes.Where(y=>y.Index==2).Select(z=>z.Code).SingleOrDefault(),
Code4 = x.Codes.Where(y=>y.Index==3).Select(z=>z.Code).SingleOrDefault(),
Qty = x.Qty
})
.ToList();
result.Dump();
As you see, static headers have been used in above code.