Datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a Master-Detail DataGrid

The detail grid is embedded inside the Mastergrid with each row.
Adding the detail grid in ItemDatabound event.



I am exporting the Grid to a Excel.

In the excel sheet only Master grid content shows up and NOT the detail grid??

Why is the detail grid not showing up in the excel??

Thanks
vinay
 
How are you doing the expert? Using Control.Render or some other
technique? Show us some code to help find the problem.
 
Yes i am using the dgReport.RenderControl


Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Dim oStringWriter As New System.IO.StringWriter
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)

oHtmlTextWriter.Write("<html><head>")

oHtmlTextWriter.Write("<style>")
oHtmlTextWriter.Write(".dataGridHeader{font-weight: bold;font-size:
8pt;color: black;font-family: Verdana;background-color: #ddddee;text-align:
left;}")
oHtmlTextWriter.Write(".dataGridItemStyle{font-size: 8pt;color:
black;font-family: Verdana;text-align: left;}")

oHtmlTextWriter.Write("</style>")
oHtmlTextWriter.Write("</head><body>")

oHtmlTextWriter.WriteBeginTag("form runat=server ")
oHtmlTextWriter.WriteAttribute("target", "_blank")
oHtmlTextWriter.Write(">")
dgReport.RenderControl(oHtmlTextWriter)
oHtmlTextWriter.Write("</form></body></html>")
Response.Write(oStringWriter.ToString())
Response.End()
 
Hi Vinay:

This code looks good. Any chance you are adding the nested DataGrid
dynamically from code? Can you verify the data bound event is firing
with the debugger?
 
Yes i am adding the Detail DataGrid dynamically ANd the event is Firing.
I can see the master-detail page . But only when i do a Export, detail
dosent show up!!
dgReferret.DataSource = dtAssigned
dgReferret.DataBind()
e.Item.Cells(9).Controls.Add(dgReferret)
 
If this is only happening during a postback though, the Item_DataBound
won't fire unless you have a DataBind on the outer grid. You have to
be careful what events you are using.
 
Scott
I got it !!!
What i did is, when i click button to export to excel.
I did a Databind to the grid, that solved it!!!!!!!!!

Thanks so much for ur idea.
"If this is only happening during a postback though, the Item_DataBound
won't fire unless you have a DataBind on the outer grid"
 
Back
Top