chandresh kalsariya

chandresh kalsariya

  • 1.7k
  • 57
  • 1.2k

store all data in index0. split string and store into array.

Jan 5 2018 6:24 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class User_Basket : System.Web.UI.Page
{
string s;
string t;
string[] a = new string[4];
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange( new DataColumn[4]{new DataColumn("Product_name"), new DataColumn("Product_qty"), new DataColumn("Product_price"), new DataColumn("Category")});
if (Request.Cookies["ck"] != null)
{
s = Convert.ToString(Request.Cookies["ck"].Values);
string[] strarr = s.Split('|');
for (int i = 0; i < strarr.Length; i++)
{
t = Convert.ToString(strarr[i].ToString());
string[] strarr1 = t.Split(',');
for (int j = 0; j < strarr1.Length; j++)
{
a[j] = strarr1[j].ToString();
}
dt.Rows.Add(a[0].ToString(), a[1].ToString(), a[2].ToString(), a[3].ToString());
// stroe all string in index 0 .
//how to fix this? 
}
}
d1.DataSource = dt;
d1.DataBind();
}
}

Answers (2)