How to add two topic categories to DataGrid

zhaozj2021-02-16  69

9CBS - Document Center - .Net Title How to add two headers to DataGrid to add two headers to Cuike519 (original) keyword double head, classification

I am writing PowerDataGrid to think of providing a query (for details on PowerDataGrid) Reference to the discussion in the 9CBS Forum, the source code can be downloaded at www.foxhis.com/powermjte/sharepowerDataGrid.rar, the constructor is like this: mine This control can display the content of the statement by specifying a SQL statement (other function is not described, this is not a key), then I can package a set of UI to this control to implement the function of the query, the problem came out, this query Usually, it should be on the DataGrid's top, how can I reserve the original head at the same time? (Double head)? The problem came out, how to solve it? I don't think of a lot of ways. If you want to redraw your header, you have to deal with the sorting is the interaction problem of the front and back, then you can only reserve the original Header's non-movable basis to add a new header. Inadvertently found in paging, there are several paging display methods. There is a selection of options in the paging panel, you can choose the top and bottom, when choosing this type, DataGrid is more in the original Header. One line, we use this line today to complete our task, today we don't generate the UI of the query, but produce a classification, we use the test database northwind to display the data, first we have to do binding data binding code as follows: SqlConnection con = new SqlConnection ( "server = localhost; database = Northwind; uid = sa; pwd =;"); SqlDataAdapter da = new SqlDataAdapter ( "SELECT LastName '' FirstName as name, BirthDate, Country , Title, Hiredate from Employees ", Con); DATATABLE DT = New DataTable (); da.fill (dt); this.DataGrid1.datasource = dt; this.dataGrid1.database.DataGrid1.Database ();} then add appropriate in Itemcreated The code is completed to complete our task, and the UI that has been created in PowerDataGrid this event handler has added it! If you add a position that needs to be judged (up and down) Pager in PowerDataGrid, we can use a global variable to determine.

Define a global variable private int m_CreatePageTimes = 0; then we add the following code handler for the event: private int m_CreatePageTimes = 0; private void DataGrid1_ItemCreated (object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {ListItemType elemType = e .Item.itemType; if (ELEMTYPE == ListItemTYPE.PAGER) {if (m_createpagetimes == 0) {TableCell CellPerson = (Tablecell) E.Item.controls [0]; cellPerson.Controls.clear (); cellperson.backcolor = Color.Navy; cellPerson.ForeColor = Color.Yellow; cellPerson.ColumnSpan = 3; cellPerson.HorizontalAlign = HorizontalAlign.Center; cellPerson.Controls.Add (new LiteralControl ( "personal information")); TableCell cellJob = new TableCell (); Celljob.backcolor = color.navy; celljob.forecolor = color.yellow; celljob.columnspan = 2; celljob.horizontalalign = horizontalalign.center; CellJob.Controls.add (New LiteralControl ("Work Information")); E.Item.controls.Add (CellJob); M_CreatePageTimes ;} else if (m_createpagetimes == 1) {// Create Custom Pager ui}} Last It is the code of DataGrid's HTML section as follows: <

转载请注明原文地址:https://www.9cbs.com/read-18522.html

New Post(0)