How display like that in gridview?
-
Hi. From Database i m getting data in this format. CAC PAT A 12/03/07 CAC PAT A 12/04/07 CAC PAT A 12/05/07 CMP CAT B 11/03/07 CMP CAT B 11/06/07 CMP CAT B 11/08/07 CPL AMT C 10/01/07 CPL AMT C 10/04/07 CPL AMT C 10/06/07 I want to display like that CAC PAT A 12/03/07 12/04/07 12/05/07 CMP CAT B 11/03/07 11/06/07 11/08/07 CPL AMT C 10/01/07 10/04/07 10/06/07 How to do ? Help me Thanks
-
Hi. From Database i m getting data in this format. CAC PAT A 12/03/07 CAC PAT A 12/04/07 CAC PAT A 12/05/07 CMP CAT B 11/03/07 CMP CAT B 11/06/07 CMP CAT B 11/08/07 CPL AMT C 10/01/07 CPL AMT C 10/04/07 CPL AMT C 10/06/07 I want to display like that CAC PAT A 12/03/07 12/04/07 12/05/07 CMP CAT B 11/03/07 11/06/07 11/08/07 CPL AMT C 10/01/07 10/04/07 10/06/07 How to do ? Help me Thanks
Use ItemDataBound Event of GridView.
-
Use ItemDataBound Event of GridView.
-
Try this is the code which i used for it.
private void DG_ItemDataBound(object o, DataGridItemEventArgs e) { // apply custom formatting to data cells if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // set formatting for the category cell TableCell cell = (e.Item.Controls[0] as TableCell); cell.Width = new Unit("120px"); cell.Style["border-right"] = "2px solid #666666"; cell.BackColor = System.Drawing.Color.LightGray; // set formatting for value cells for(int i=1; i= 8000) and apply special highlighting if (GetCellValue(cell) >= 8000) { cell.Font.Bold = true; cell.BorderWidth = new Unit("1px"); cell.BorderColor = System.Drawing.Color.Gray; cell.BorderStyle = BorderStyle.Dotted; cell.BackColor = System.Drawing.Color.Honeydew; } } } // apply custom formatting to the header cells if (e.Item.ItemType == ListItemType.Header) { foreach (TableCell cell in e.Item.Controls) { cell.Style["border-bottom"] = "2px solid #666666"; cell.BackColor=System.Drawing.Color.LightGray; } } }
It is an Example only try it with your specs.SSK.
-
Item Data Bound is the event which is fired before u bind the GridView Control, so either u can fire a query where u will get the ID and Different dates and then match that ID with the e.Row.Cells[0].Text and do something like this: e.Row.Cells[1].Text= //Put all the different date in a string variable separated by
Before this u will have to write the above code in this if statement: if (e.Row.RowType == DataControlRowType.DataRow) { } I am not sure about the syntax. But u can get it. Hope u understood the code. -
Hi. From Database i m getting data in this format. CAC PAT A 12/03/07 CAC PAT A 12/04/07 CAC PAT A 12/05/07 CMP CAT B 11/03/07 CMP CAT B 11/06/07 CMP CAT B 11/08/07 CPL AMT C 10/01/07 CPL AMT C 10/04/07 CPL AMT C 10/06/07 I want to display like that CAC PAT A 12/03/07 12/04/07 12/05/07 CMP CAT B 11/03/07 11/06/07 11/08/07 CPL AMT C 10/01/07 10/04/07 10/06/07 How to do ? Help me Thanks
hey guy first of all where u want to display the format in crystal or other if in crystal report make a group go to group insert group select the datatable column name it will be work. byeeeeeeeee lucky
-
Try this is the code which i used for it.
private void DG_ItemDataBound(object o, DataGridItemEventArgs e) { // apply custom formatting to data cells if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // set formatting for the category cell TableCell cell = (e.Item.Controls[0] as TableCell); cell.Width = new Unit("120px"); cell.Style["border-right"] = "2px solid #666666"; cell.BackColor = System.Drawing.Color.LightGray; // set formatting for value cells for(int i=1; i= 8000) and apply special highlighting if (GetCellValue(cell) >= 8000) { cell.Font.Bold = true; cell.BorderWidth = new Unit("1px"); cell.BorderColor = System.Drawing.Color.Gray; cell.BorderStyle = BorderStyle.Dotted; cell.BackColor = System.Drawing.Color.Honeydew; } } } // apply custom formatting to the header cells if (e.Item.ItemType == ListItemType.Header) { foreach (TableCell cell in e.Item.Controls) { cell.Style["border-bottom"] = "2px solid #666666"; cell.BackColor=System.Drawing.Color.LightGray; } } }
It is an Example only try it with your specs.SSK.