I have a grid that works fine otherwise, but when I export it (regardless of Excel, CSV, PDF, etc.) their are two issues:
(1) The first issue is that hypercolumns are shown as blank in the exported file even the programmatic definition is "exportable = false";
(2) All of the columns that contain boundcolumn's only contain the value "System.Data.DataRowView" text instead of the values from the grid (
which display correctly).
I have read other forum entries that discuss this textual value, but they pretty much have to do with data column names not matching the grid column names -- and that is not the case.
I have attached:
(1) a screen capture of the displayed grid with one of the export files superimposed showing the results. Please remember that is does NOT matter which export file format I select.
(2) the .aspx display file source that I can distribute;
(3) the master file source that I can distribute; and,
(4) the code behind file source code that I can distribute.
Any help anyone can provide would be most appreciated!
Lynn
Source code follows:
the .aspx display file source that I can distribute:
the master file source that I can distribute:
the code behind file source code that I can distribute:
The sql code to the stored procedure being used:
the master file source that I can distribute
(1) The first issue is that hypercolumns are shown as blank in the exported file even the programmatic definition is "exportable = false";
(2) All of the columns that contain boundcolumn's only contain the value "System.Data.DataRowView" text instead of the values from the grid (
which display correctly).
I have read other forum entries that discuss this textual value, but they pretty much have to do with data column names not matching the grid column names -- and that is not the case.
I have attached:
(1) a screen capture of the displayed grid with one of the export files superimposed showing the results. Please remember that is does NOT matter which export file format I select.
(2) the .aspx display file source that I can distribute;
(3) the master file source that I can distribute; and,
(4) the code behind file source code that I can distribute.
Any help anyone can provide would be most appreciated!
Lynn
Source code follows:
the .aspx display file source that I can distribute:
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"server"
>
<
h3
>
Agents with Expiring Licenses
</
h3
>
<
p
>
These Agents have licenses that are expiring soon.
</
p
>
<
div
class
=
"container"
>
<
div
class
=
"row10"
>
<
div
class
=
"one column"
>
</
div
>
<
div
class
=
"fourteen columns"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowSorting
=
"True"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
Width
=
"99.7%"
AutoGenerateColumns
=
"false"
AllowPaging
=
"false"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
AllowFilteringByColumn
=
"True"
>
<
ExportSettings
HideStructureColumns
=
"true"
Csv-ColumnDelimiter
=
"Comma"
IgnorePaging
=
"true"
OpenInNewWindow
=
"true"
ExportOnlyData
=
"true"
>
</
ExportSettings
>
<
MasterTableView
Width
=
"100%"
CommandItemDisplay
=
"Top"
EnableViewState
=
"true"
>
<
PagerStyle
Mode
=
"Slider"
></
PagerStyle
>
<
CommandItemTemplate
>
<
table
class
=
"rcCommandTable"
width
=
"100%"
>
<
tr
>
<
td
style
=
"float: right; vertical-align:middle;"
>
<
asp:ImageButton
runat
=
"server"
ID
=
"btnCSVExport"
ImageUrl
=
"../Icons/csvdownload.jpg"
CommandName
=
"ExportToCSV"
Height
=
"24px"
Width
=
"24px"
ToolTip
=
"Export to CSV"
/>
<
asp:ImageButton
runat
=
"server"
ID
=
"btnExcelExport"
ImageUrl
=
"../Icons/excel.png"
CommandName
=
"ExportToExcel"
Height
=
"24px"
Width
=
"24px"
ToolTip
=
"Export to Excel"
/>
<
asp:ImageButton
runat
=
"server"
ID
=
"btnWordExport"
ImageUrl
=
"../Icons/ms_word_2.png"
CommandName
=
"ExportToWord"
Height
=
"24px"
Width
=
"24px"
ToolTip
=
"Export to Word"
/>
<
asp:ImageButton
runat
=
"server"
ID
=
"btnPDFExport"
ImageUrl
=
"../Icons/Pdf.png"
CommandName
=
"ExportToPDF"
Height
=
"24px"
Width
=
"24px"
ToolTip
=
"Export to PDF"
/>
</
td
>
</
tr
>
</
table
>
</
CommandItemTemplate
>
<
CommandItemSettings
ShowExportToWordButton
=
"true"
ShowExportToExcelButton
=
"true"
ShowExportToCsvButton
=
"true"
ShowExportToPdfButton
=
"true"
>
</
CommandItemSettings
>
<
Columns
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
div
>
<
div
class
=
"one column"
>
</
div
>
</
div
>
</
div
>
<
br
/>
<
div
class
=
"container"
>
<
div
class
=
"row10"
>
<
div
class
=
"sixteen columns"
style
=
"text-align: center;"
>
<
telerik:RadButton
ID
=
"CloseMe"
runat
=
"server"
Text
=
"Close Window"
CausesValidation
=
"False"
ToolTip
=
"Closes this window."
UseSubmitBehavior
=
"False"
OnClientClicked
=
"closemenow"
/>
</
div
>
</
div
>
</
div
>
<
div
class
=
"container"
>
<
div
class
=
"row10"
>
<
div
class
=
"sixteen columns"
style
=
"text-align: center;"
>
<
asp:Label
ID
=
"PageErrors"
runat
=
"server"
Font-Bold
=
"True"
ForeColor
=
"#C00000"
Width
=
"95%"
></
asp:Label
>
</
div
>
</
div
>
</
div
>
</
asp:Content
>
the master file source that I can distribute:
<
body
id
=
"page1"
>
<
telerik:RadFormDecorator
Skin
=
"Office2010Silver"
Enabled
=
"true"
ID
=
"QsfFormDecorator"
DecorationZoneID
=
"rfd-demo-zone"
runat
=
"server"
DecoratedControls
=
"All"
EnableRoundedCorners
=
"true"
EnableEmbeddedSkins
=
"true"
/>
<
telerik:RadSkinManager
ID
=
"RadSkinManager1"
runat
=
"server"
></
telerik:RadSkinManager
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
id
=
"rfd-demo-zone"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
div
id
=
"content"
>
<
div
class
=
"main"
>
<
div
class
=
"xcontainer"
>
<
div
class
=
"row-main-25"
style
=
"padding-bottom: 10px; "
>
<!-- navbar start -->
<
div
class
=
"sixteen columns "
>
<
div
class
=
"menucontainer"
>
<
section
id
=
"loginx"
>
<
asp:LoginView
ID
=
"LoginView1"
runat
=
"server"
ViewStateMode
=
"Disabled"
>
<
AnonymousTemplate
>
<
ul
class
=
"sessionnav"
id
=
"Ul1"
runat
=
"server"
style
=
"margin-bottom: 10px; padding-top: 4px; padding-bottom: 6px;"
>
<
li
><
a
id
=
"A4"
runat
=
"server"
onclick
=
"doNothing();"
title
=
"If checked, the site will attempt to display pages by re-using the same window. If you are using a mobile device this will reduce the number of pages opened."
>Reuse Windows</
a
><
asp:CheckBox
ID
=
"ReuseWindow1"
runat
=
"server"
onclick
=
"doClick(this)"
AutoPostBack
=
"true"
ToolTip
=
"If checked, the site will attempt to display pages by re-using the same window. If you are using a mobile device this will reduce the number of pages opened by Broker+."
/></
li
>
<
li
><
a
id
=
"A3"
runat
=
"server"
href
=
"~/Account/Login.aspx"
>Log in</
a
></
li
>
<
li
><
a
id
=
"A2"
runat
=
"server"
href
=
"~/Account/Register.aspx"
>Register</
a
></
li
>
</
ul
>
</
AnonymousTemplate
>
<
LoggedInTemplate
>
<
ul
class
=
"sessionnav"
id
=
"Ul2"
runat
=
"server"
style
=
"margin-bottom: 10px; padding-top: 4px; padding-bottom: 6px;"
>
<
li
><
a
id
=
"A5"
runat
=
"server"
onclick
=
"doNothing();"
title
=
"If checked, the site will attempt to display pages by re-using the same window. If you are using a mobile device this will reduce the number of pages opened by Broker+."
>Reuse Windows</
a
><
asp:CheckBox
ID
=
"ReuseWindow2"
runat
=
"server"
onclick
=
"doClick(this)"
AutoPostBack
=
"true"
ToolTip
=
"If checked, the site will attempt to display pages by re-using the same window. If you are using a mobile device this will reduce the number of pages opened by Broker+."
/></
li
>
<
li
><
a
id
=
"A1"
runat
=
"server"
class
=
"username"
href
=
"~/Account/MyAccount.aspx"
title
=
"Manage your account"
><
asp:LoginName
ID
=
"LoginName1"
runat
=
"server"
CssClass
=
"username"
/></
a
></
li
>
<
li
><
asp:LoginStatus
ID
=
"LoginStatus1"
runat
=
"server"
CssClass
=
"username"
LogoutAction
=
"Redirect"
LogoutText
=
"Log off"
LogoutPageUrl
=
"~/logout.aspx"
/></
li
>
</
ul
>
<
div
class
=
"clear"
></
div
>
</
LoggedInTemplate
>
</
asp:LoginView
>
</
section
>
</
div
>
</
div
>
<!-- navbar end -->
<!-- logo start -->
<
div
class
=
"row10"
style
=
"height: 90px; "
>
<
div
class
=
"sixteen columns header-bg"
style
=
"height: 90px;"
>
<
div
style
=
"float: left; "
>
<
img
src
=
""
/>
</
div
>
<
div
class
=
"zippy"
style
=
"margin-left: 0px; float: left; height: 90px; text-align: center; overflow: no-display;"
>
<
div
class
=
"slogan-line"
>
<
telerik:RadTicker
AutoStart
=
"true"
runat
=
"server"
ID
=
"Radticker1"
loop
=
"false"
DataSourceID
=
"SqlDataSource1"
DataTextField
=
"ScrollerText"
>
</
telerik:RadTicker
>
</
div
>
</
div
>
<
div
class
=
"findus"
style
=
"float: right; height: 90px; text-align: center; background-color: black; "
>
<
div
class
=
"header-icons-and-phone"
>
<
div
class
=
"header-icons-links"
>
<
img
alt
=
"youtube icon"
src
=
"<%=Page.ResolveUrl("
~/Icons/youtube.png")%>" height="24" width="24" />
<
img
alt
=
"facebook icon"
src
=
"<%=Page.ResolveUrl("
~/Icons/facebook.png")%>" height="24" width="24" />
<
img
alt
=
"twitter icon"
src
=
"<%=Page.ResolveUrl("
~/Icons/twitter.png")%>" height="24" width="24" />
</
div
>
<
div
class
=
"header-icons-links2"
>
<
asp:Label
Text
=
"Have questions?"
ID
=
"Label2"
runat
=
"server"
Font-Bold
=
"true"
Font-Italic
=
"true"
Font-Names
=
"Times New Roman"
Font-Size
=
"16px"
ForeColor
=
"#11bcf0"
></
asp:Label
>
<
br
/>
<
asp:Label
Text
=
""
ID
=
"Label3"
runat
=
"server"
Font-Bold
=
"true"
Font-Size
=
"16px"
ForeColor
=
"white"
></
asp:Label
>
</
div
>
</
div
>
<
div
class
=
"clear"
></
div
>
</
div
>
<
div
class
=
"clear"
></
div
>
</
div
>
</
div
>
<!-- logo end -->
<!-- menu start -->
<
div
class
=
"row10"
style
=
"width: 100%; background-color: black; "
>
<
div
class
=
"sixteen columns "
>
<
div
class
=
"menubar"
>
<
THDi:BrokerPlusMenu
ID
=
"BrokerPlusMenu1"
runat
=
"server"
MenuToLoad
=
"Broker+ Office"
ProfileName
=
"Office"
/>
</
div
>
</
div
>
</
div
>
<!-- menu end -->
<
asp:ContentPlaceHolder
ID
=
"ContentPlaceHolder1"
runat
=
"server"
>
</
asp:ContentPlaceHolder
>
</
div
>
the code behind file source code that I can distribute:
protected
void
Page_Init(
object
sender, System.EventArgs e)
{
if
(!Page.IsPostBack)
{
sType = Request[
"T"
];
string
sUserFormRules = Convert.ToString(Session[
"UserBrokerPlusFormsRules"
]);
string
sRule =
""
;
this
.RadGrid1.AllowFilteringByColumn =
true
;
GridHyperLinkColumn hypercolumn =
null
;
GridBoundColumn boundcolumn =
null
;
hypercolumn =
new
GridHyperLinkColumn();
hypercolumn.HeaderText =
"Edit"
;
hypercolumn.UniqueName =
"Agent"
;
hypercolumn.Text =
"<img border=\"0\" alt=\"View\" src=\"../Icons/pencil_16.png\" />"
;
hypercolumn.DataNavigateUrlFields =
new
string
[] {
"Agent"
};
hypercolumn.DataNavigateUrlFormatString =
"OfcAgentEdit.aspx?M=Y&T="
+ sType +
"K="
+
"{"
+
"0"
+
"}"
;
hypercolumn.AllowFiltering =
false
;
hypercolumn.HeaderStyle.Width = Unit.Pixel(50);
hypercolumn.Exportable =
false
;
this
.RadGrid1.MasterTableView.Columns.Add(hypercolumn);
hypercolumn =
new
GridHyperLinkColumn();
hypercolumn.HeaderText =
"Email"
;
hypercolumn.UniqueName =
"SendAgentMail"
;
hypercolumn.Text =
"<img border=\"0\" alt=\"View\" src=\"../Icons/mailIcon.gif\" />"
;
hypercolumn.DataNavigateUrlFields =
new
string
[] {
"AgentEmail"
};
hypercolumn.DataNavigateUrlFormatString =
"mailto:"
+
"{"
+
"0"
+
"}"
;
hypercolumn.HeaderStyle.Width = Unit.Pixel(30);
hypercolumn.AllowFiltering =
false
;
hypercolumn.Exportable =
false
;
this
.RadGrid1.MasterTableView.Columns.Add(hypercolumn);
boundcolumn =
new
GridBoundColumn();
boundcolumn.UniqueName =
"AgentID"
;
boundcolumn.DataField =
"AgentID"
;
boundcolumn.HeaderText =
"ID"
;
boundcolumn.FilterControlWidth = Unit.Pixel(50);
boundcolumn.HeaderStyle.CssClass =
"mediumgridcol"
;
boundcolumn.ItemStyle.CssClass =
"mediumgridcol"
;
boundcolumn.FooterStyle.CssClass =
"mediumgridcol"
;
boundcolumn.Visible =
true
;
boundcolumn.Exportable =
true
;
this
.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
boundcolumn =
new
GridBoundColumn();
boundcolumn.UniqueName =
"AgentFullName"
;
boundcolumn.DataField =
"AgentFullName"
;
boundcolumn.HeaderText =
"Name"
;
boundcolumn.HeaderStyle.Width = Unit.Pixel(240);
boundcolumn.FilterControlWidth = Unit.Pixel(100);
boundcolumn.Visible =
true
;
this
.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
boundcolumn =
new
GridBoundColumn();
boundcolumn.UniqueName =
"AgentCellular"
;
boundcolumn.DataField =
"AgentCellular"
;
boundcolumn.HeaderText =
"Cellular"
;
boundcolumn.FilterControlWidth = Unit.Pixel(60);
boundcolumn.HeaderStyle.CssClass =
"smallgridcol"
;
boundcolumn.ItemStyle.CssClass =
"smallgridcol"
;
boundcolumn.FooterStyle.CssClass =
"smallgridcol"
;
boundcolumn.Visible =
true
;
boundcolumn.Visible =
true
;
this
.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
boundcolumn =
new
GridBoundColumn();
boundcolumn.UniqueName =
"AgentEmail"
;
boundcolumn.DataField =
"AgentEmail"
;
boundcolumn.HeaderText =
"Email"
;
boundcolumn.HeaderStyle.CssClass =
"smallgridcol"
;
boundcolumn.ItemStyle.CssClass =
"smallgridcol"
;
boundcolumn.FooterStyle.CssClass =
"smallgridcol"
;
boundcolumn.Visible =
true
;
boundcolumn.Visible =
true
;
boundcolumn.FilterControlWidth = Unit.Pixel(100);
this
.RadGrid1.MasterTableView.Columns.Add(boundcolumn);
RadGrid1.AllowPaging = Convert.ToBoolean(Session[
"ShowListsWithPaging"
]);
RadGrid1.PageSize = 20;
}
else
{
sType = Request[
"T"
];
}
}
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
// this code is used to make filter columns visible/invisible as the grid grows/shrinks
if
(e.Item
is
GridFilteringItem)
{
GridFilteringItem Filter = (GridFilteringItem)e.Item;
Filter[
"AgentID"
].CssClass =
"mediumgridcol"
;
Filter[
"AgentCellular"
].CssClass =
"smallgridcol"
;
Filter[
"AgentEmail"
].CssClass =
"smallgridcol"
;
}
}
protected
void
CreateNew_Click(
object
sender, EventArgs e)
{
Response.Redirect(
"OfcAgentEdit.aspx?M=N&K=&T="
+ sType);
}
public
DataTable GetDataTable()
{
String ConnString = System.Configuration.ConfigurationManager.ConnectionStrings[
"BrokerPlus"
].ConnectionString;
DataTable dt =
new
DataTable();
//string sStatusNeeded = "";
DateTime dt1 = Convert.ToDateTime(
"9/1/2014"
);
using
(SqlConnection sqlcon =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"BrokerPlus"
].ConnectionString))
{
using
(SqlCommand cmd =
new
SqlCommand(
"[Agents_GetAllByAgent_ExpiringLicenses2]"
, sqlcon))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(
new
SqlParameter(
"@Account"
, Convert.ToInt32(Session[
"UserAccount"
])));
cmd.Parameters.Add(
new
SqlParameter(
"@Agent_Expire"
, dt1));
using
(SqlDataAdapter da =
new
SqlDataAdapter(cmd))
{
da.Fill(dt);
return
dt;
}
}
}
}
protected
void
RadGrid1_NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = GetDataTable();
}
}
}
The sql code to the stored procedure being used:
CREATE
PROCEDURE
[dbo].[Agents_GetAllByAgent_ExpiringLicenses2]
(
@Account
int
,
@Agent_Expire
date
)
AS
SELECT
Agent, AgentEmail, AgentID, AgentFullName, AgentCellular, AgentLicenseExpires, Agent_Account
FROM
Agents
WHERE
AgentLicenseExpires < @Agent_Expire
AND
Agent_Account = @Account
the master file source that I can distribute