1

What's the simplest way to bind my grid view to a single data row :

I have the following data for example :

dep_code = 3;
dep_name = "computer science";
boss_num = 356;
boss_name ="Ahmed";

i want to bind those data on my gridview.

Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
  • 1
    What have you tried, what was the problem? Why do you need a `GridView` for a single record? You can use a `DetailsView` or `FormView`. – Tim Schmelter Mar 13 '13 at 08:36
  • i have 4 values like the above , and i want to bind them on my grid view(one record) , can i use anonymous object or some way!! or i have to create a data table – Anyname Donotcare Mar 13 '13 at 08:38
  • I think the most easiest way is to create a `DataTable`. As your `GridView` probably has column headers to? Which can be defined in your `DataTable` as well. – Mike de Klerk Mar 13 '13 at 08:39
  • @just_name: You can create a `DataTable` or an anonymous type, both approaches are pretty easy, so i don't understand the problem. – Tim Schmelter Mar 13 '13 at 08:39
  • i ask about the most convenient way to bind one record . – Anyname Donotcare Mar 13 '13 at 08:41

1 Answers1

2

I think List of list should be simplest

List<List<string>> list = {{dep_code,dep_name,boss_num,boss_name}};
GridView1.DataSource = list;
GridView1.DataBind();
शेखर
  • 17,412
  • 13
  • 61
  • 117