gridview中的模板字段 [英] template field in a gridview
问题描述
如何创建TreeView类型GridView [ ^ ]
在上面引用的代码中,我在gridview中添加了一个模板字段
TemplateField tfield = new TemplateField();
tfield.HeaderText =abc;
GridView1.Columns.Add(tfield);
如何在其中加入值。我想在模板字段中放两个值。
列名
3月2日
0.4 aug
4.5 sep
这两个值将来自数据库的不同列。
如何使用c#动态执行此操作?
请回答以上引用的代码。
请按下按钮,考虑回发的情况。向TemplateField添加2个文字控件可能无法在回发后显示数据。
如果可以使用Itemplate完成,那么我应该添加哪些控件?
如果可能,请用几行代码解释。
查看本教程。我认为它会对你有所帮助
http: //msdn.microsoft.com/en-us/library/bb288032.aspx [ ^ ]
本教程中,我们将使用TemplateFields来自定义员工列表的外观。具体来说,我们将列出所有员工,但会在一列中显示员工的名字和姓氏,在日历控件中显示他们的雇用日期,以及表明他们在公司工作了多少天的状态列。
How to Create TreeView Type GridView[^]
In the above referenced code, I have added a template field to the gridview
TemplateField tfield = new TemplateField(); tfield.HeaderText = "abc"; GridView1.Columns.Add(tfield);
How can I put values in it. I want to put two values in the template field.
column name
2.3 july
0.4 aug
4.5 sep
the two values will come from different columns of the database.
How can I do it dynamically using c#?
Please answer in relation to the above referenced code.
Please consider the case of a postback on pressing a button. Adding 2 literal controls to TemplateField may fail to display the data after postback.
If it can be done with Itemplate, then what controls should I add?
If possible explain with few lines of code.
Check this tutorial. I think it will help you
http://msdn.microsoft.com/en-us/library/bb288032.aspx[^]
This tutorial, we will use TemplateFields to customize the appearance of a list of employees. Specifically, we'll list all of the employees, but will display the employee's first and last names in one column, their hire date in a Calendar control, and a status column that indicates how many days they've been employed at the company.
这篇关于gridview中的模板字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!