asp.net in the DataGrid double row cross column cross row complex table head design experience!
Source: Internet
Author: User
asp.net|datagrid| Design | experience
property settings for a DataGrid
1. Allowpaging:true
2. Pagestyle->position:topandbottom
3. Optional: Pagestyle->horizonalign:center (make text centered)
4. Optional: Itemstyle->horizonalign:center (make text centered)
Second, the Code section
1. First, make the DataGrid bind to a table in the database, for example:
private void Page_Load (object sender, System.EventArgs e)
{
Place user code here to initialize page
if (! IsPostBack)
{
SqlConnection myconn=new SqlConnection ("Server=localhost;uid=sa;pwd=sa;database=db_test");
SqlDataAdapter Da=new SqlDataAdapter ("select * from individual", myconn);
DataSet ds=new DataSet ();
Da. Fill (ds, "gr");
Dggeren.datasource=ds. Tables["GR"]. DefaultView;
Dggeren.databind ();
}
2. Add the handler function for the ItemCreated event for the DataGrid,
3. In order to determine the position of the two (up and down) pager in the DataGrid, we can use a global variable to determine.
Define a global variable private int m_createpagetimes = 0;
4. Add content to the handler function for the ItemCreated event of the DataGrid, as follows:
private void Dggeren_itemcreated (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
Switch (e.item.itemtype)
{
Case (Listitemtype.pager):
Case Listitemtype.pager:
{
if (m_createpagetimes = 0)
{
DataGridItem row= (DataGridItem) E.item;
Row. Cells.clear ();
Row. Backcolor=color.navy; Background color
Row. forecolor=color.red; Foreground color
Row. horizontalalign=horizontalalign.center;//Text to the center
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.