想在网格视图中显示这样的数据 [英] want to show data like this in grid view
本文介绍了想在网格视图中显示这样的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
S.NO ID 1 Date 12/03/2014 DateofRelief 15/3/2014
ApplicantName ABC S/o PQR This sort of action has been taken
Complaint Detail ABC has filed complaint regarding this.
推荐答案
请参阅以下示例并根据您的需求进行投诉:
在你的aspx文件中说你有一个gridview控件,其id为GridView1;
的代码隐藏文件>创建数据表>将相应列添加到数据表>在数据表中逐行填充数据>将数据表绑定到GridView1
See the following example and adapt to your needs:
Say in your aspx file you have a gridview control whose id is "GridView1";
on its code behind file > create a datatable > add the respective columns to the datatable > populate data row by row in the datatable > bind the datatable to GridView1
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == true)
return;
DataTable dtTemp = new DataTable();
// columns headings
dtTemp.Columns.Add("Student ID");
dtTemp.Columns.Add("First Name");
dtTemp.Columns.Add("Last Name");
// insert data row by row
dtTemp.Rows.Add("1", "Peter", "Leow");
dtTemp.Rows.Add("2", "James", "Song");
dtTemp.Rows.Add("3", "Mick", "Sam");
dtTemp.Rows.Add("4", "MAry", "Cool");
// bind datasource
GridView1.DataSource = dtTemp;
GridView1.DataBind();
}
结束。
The End.
>使用这些参数作为其属性创建实体
>如果需要,创建这些实体的列表
>将其分配给gridview数据源并使用Databind()
>Create an entity with these parameters as its properties
>Create a list of these entities if required
>Assign it to gridview Datasource & use Databind()
这篇关于想在网格视图中显示这样的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文