I have to use datatable and make things like given in the image
the data must be picked from the database and then retrieved by ajax the retrieve function will be looking like
public static List<string[]> AllItems()
{
List<string[]> ItemList = new List<string[]>();
using (MySqlConnection exmp = new MySqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString))
{
using (MySqlCommand getAllItems = new MySqlCommand())
{
getAllItems.Connection = exmp;
getAllItems.CommandType = CommandType.Text;
getAllItems.CommandText = "SELECT * FROM table1";
exmp.Open();
MySqlDataReader reader = getAllItems.ExecuteReader();
while (reader.Read())
{
string[] temp = new string[8];
//Item Name
temp[0] = reader[0].ToString();
// Item Nick Name
temp[1] = reader[1].ToString();
//Item property
temp[2] = reader[2].ToString();
//Item Image URl
temp[3] = reader[3].toString();
//Item Price
temp[4] = reader[4].toString();
//Item Special Property that makes a link
temp[5] = reader[5].toString();
ItemList.Add(temp);
}
}
}
return ItemList;
}
My ajax function to retrieve json
$.ajax({
type: "POST",
url: "default.aspx/AllItems",
data: {},
contentType: "application/json",
dataType: "json",
success: OnSuccess
});
Now using the code given above for retrieving data from database, I have to make a structure as given in the pic mentioned above using datatables How can I do it?
Please provide some sample code; I'll be grateful to you.