The main data is pulled from SQLDataSource and the translation that used in the methods are pulling from the XMLDataSource. But when I try to export it's only show ID instead of the name field.
aspx
Text='<%# getProdName( DataBinder.Eval(Container.DataItem,"ProdID").ToString()) %>'
code behind
protected string getProdName(string ID)
{
string strProduct = string.Empty;
.......
return strProduct;
}
dt = info.GetData(); //dt is a DataTable.
RadGrid1.DataSource = dt; (where dt is a datatable created from an xml file.)
Grid aspx is here:
<div id="grid">
<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting="true"
AutoGenerateColumns="False" AllowPaging="True"
OnNeedDataSource="RadGrid1_NeedDataSource" GridLines="None">
<MasterTableView AllowCustomSorting="true" DataKeyNames="BFNumber">
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<Columns>
<telerik:GridBoundColumn SortExpression="Number" HeaderText="Number" DataField="Number" UniqueName="Number"></telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="Type" HeaderText="Type" DataField="Type" UniqueName="Type"></telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="Status" HeaderText="Status" DataField="Status"></telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="Description" HeaderText="Description" DataField="Description"></telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="CreatedDate" HeaderText="Created Date" DataField="CreatedDate"></telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="ClosedDate" HeaderText="Closed Date" DataField="ClosedDate"></telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="AssignedDate" HeaderText="Assigned Date" DataField="AssignedDate"></telerik:GridBoundColumn>
<telerik:GridBoundColumn SortExpression="AssignedTo" HeaderText="AssignedTo" DataField="AssignedTo"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<PagerStyle Mode="NumericPages" />
</telerik:RadGrid>
</div>
But no column ever gets sorted (the down arrow and up arrow gets displayed, so it is supposedly setup to sort), so I must have done something wrong. I tried just creating a new telerik project, and used an MS Access database as the datasource, and sorting was working fine.
Thanks.
I’m new to RadScheduler and I have built a scheduler that several people update through the day and because someone else may have added an event to the schedule others will refresh their view often. The problem is that when you refresh the page the last event you added on that page gets duplicated every time you refresh the page until you move to another page. Is there a way to keep this from happening?
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
IconUrl
=
"../CSS/titlegraphic.gif"
>
</
telerik:RadWindowManager
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
</
Scripts
>
</
asp:ScriptManager
>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"ReportGrid"
Width
=
"936px"
GridLines
=
"Horizontal"
AllowPaging
=
"True"
AllowSorting
=
"True"
AllowFilteringByColumn
=
"True"
PageSize
=
"10"
OnNeedDataSource
=
"ReportGrid_NeedDataSource"
OnUpdateCommand
=
"ReportGrid_UpdateCommand"
>
<
MasterTableView
DataKeyNames
=
"pa,report_close_id"
AutoGenerateColumns
=
"false"
EditMode
=
"InPlace"
CommandItemDisplay
=
"None"
>
<
FilterItemStyle
HorizontalAlign
=
"Center"
/>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
HeaderText
=
"Edit"
HeaderStyle-Width
=
"66px"
HeaderStyle-HorizontalAlign
=
"Center"
>
<
ItemStyle
Width
=
"66px"
HorizontalAlign
=
"Center"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
DataField
=
"report_close_id"
HeaderText
=
"Report Close ID"
UniqueName
=
"report_close_id"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"client_id"
HeaderText
=
"Client ID"
UniqueName
=
"client_id"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"client_name"
HeaderText
=
"Client Name"
ReadOnly
=
"true"
UniqueName
=
"client_name"
Visible
=
"true"
HeaderStyle-Width
=
"215px"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"pa"
HeaderText
=
"Performance Analyst"
ReadOnly
=
"true"
UniqueName
=
"pa"
Visible
=
"true"
HeaderStyle-Width
=
"165px"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"requested_date"
HeaderText
=
"Requested Completion By"
UniqueName
=
"requested_date"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderStyle-Width
=
"120px"
>
<
ItemStyle
HorizontalAlign
=
"Center"
Width
=
"120px"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblRequestedDate"
runat
=
"server"
Text='<%# Bind("requested_date", "{0:MM/dd/yyyy}") %>'></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDatePicker
ID
=
"RequestedDatePicker"
runat
=
"server"
Width
=
"90px"
DbSelectedDate='<%# Bind("requested_date", "{0:MM/dd/yyyy}") %>'>
</
telerik:RadDatePicker
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"actual_date"
HeaderText
=
"Date Completed"
UniqueName
=
"actual_date"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderStyle-Width
=
"120px"
>
<
ItemStyle
HorizontalAlign
=
"Center"
Width
=
"120px"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblCompletedDate"
runat
=
"server"
Text='<%# Bind("actual_date", "{0:MM/dd/yyyy}") %>'></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDatePicker
ID
=
"CompletedDatePicker"
runat
=
"server"
Width
=
"90px"
DbSelectedDate='<%# Bind("actual_date", "{0:MM/dd/yyyy}") %>'>
</
telerik:RadDatePicker
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"comments"
HeaderText
=
"Comments"
UniqueName
=
"comments"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderStyle-Width
=
"210px"
ItemStyle-Width
=
"210px"
ItemStyle-HorizontalAlign
=
"Center"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblComments"
runat
=
"server"
Text='<%# Eval("comments") %>'></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadTextBox
ID
=
"txtComments"
runat
=
"server"
MaxLength
=
"500"
Width
=
"175px"
Rows
=
"3"
Text='<%# Eval("comments") %>' TextMode="MultiLine">
</
telerik:RadTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
br
/>
<
asp:Button
ID
=
"btnSave"
runat
=
"server"
Text
=
"Save"
visible
=
"false"
/>
<
asp:Button
ID
=
"btnCancel"
runat
=
"server"
Text
=
"Cancel/Exit"
OnClientClick
=
"Close()"
/>
</
telerik:RadAjaxPanel
>
protected
void
ReportGrid_UpdateCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.UpdateCommandName)
{
try
{
//Get the GridEditableItem of the RadGrid
GridEditableItem editedItem = e.Item
as
GridEditableItem;
int
report_close_id = Convert.ToInt32(editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex][
"report_close_id"
].ToString());
ReportCloseDateBO updated_close =
new
ReportCloseDateBO();
updated_close.FillByCloseDateID(report_close_id);
DateTime actual_date_cell =
new
DateTime();
DateTime requested_date_cell =
new
DateTime();
DateTime updated_requested_completion_date =
new
DateTime(1855, 1, 1);
DateTime updated_actual_completion_date =
new
DateTime(1855, 1, 1);
string
comments = ((editedItem[
"comments"
].Controls[1]
as
RadTextBox).Text);
ClientBO client =
new
ClientBO();
client.FillClientByID(updated_close.client_id);
bool
pa_assigned =
true
;
string
pa_email =
""
;
bool
actual_completion_changed =
false
;
bool
requested_completion_changed =
false
;
bool
error_ind =
false
;
PERAPositionBO peraPosition =
new
PERAPositionBO();
if
(!(editedItem[
"actual_date"
].Controls[1]
as
RadDatePicker).IsEmpty)
{
actual_date_cell = ((editedItem[
"actual_date"
].Controls[1]
as
RadDatePicker).SelectedDate.Value);
}
else
{
actual_date_cell =
new
DateTime(1855, 1, 1);
}
if
(!(editedItem[
"requested_date"
].Controls[1]
as
RadDatePicker).IsEmpty )
{
requested_date_cell = ((editedItem[
"requested_date"
].Controls[1]
as
RadDatePicker).SelectedDate.Value);
}
else
{
requested_date_cell =
new
DateTime(1855, 1, 1);
}
if
(client.pa_user_id != -1)
{
ApplicationUserBO pa_user =
new
ApplicationUserBO();
pa_user.FillByUserID(client.pa_user_id);
pa_email = pa_user.e_mail;
}
else
{
pa_assigned =
false
;
}
//First check to see if the requested completion date has changed
if
(requested_date_cell !=
null
)
{
//Check to see if the value has already been entered into the database
updated_requested_completion_date = requested_date_cell;
if
(updated_close.requested_completion != updated_requested_completion_date)
{
requested_completion_changed =
true
;
}
else
{
requested_completion_changed =
false
;
}
}
else
{
requested_completion_changed =
false
;
}
//Now check to see if a value has been entered into the actual completion date cell
if
(actual_date_cell !=
null
)
{
//Check to see if the value has already been entered into the database
updated_actual_completion_date = actual_date_cell;
if
(updated_close.actual_completion != updated_actual_completion_date)
{
actual_completion_changed =
true
;
}
else
{
actual_completion_changed =
false
;
}
}
else
{
actual_completion_changed =
false
;
}
//Update the request date
if
(requested_completion_changed)
{
try
{
updated_close.UpdateRequestedReportCloseDate(report_close_id, updated_requested_completion_date, comments);
}
catch
(Exception exe)
{
error_ind =
true
;
//MessageBox.Show(exe.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//logger.RecordMessage(exe, Log.MessageType.Error, parent.UserID);
}
}
//Update the actual completion date
if
(actual_completion_changed)
{
try
{
updated_close.UpdateActualReportCloseDate(report_close_id, updated_actual_completion_date, comments);
updated_close =
new
ReportCloseDateBO();
updated_close.FillByCloseDateID(report_close_id);
//Now calculate the PERA position and put it in the pera position table.
peraPosition =
new
PERAPositionBO();
peraPosition.InsertPERAPosition(updated_close.client_id, updated_close.report_dated);
//offer to notify the PA via email
if
(pa_assigned)
{
int
sendEmail = Convert.ToInt32(ConfigurationManager.AppSettings[
"SendEmail"
]);
if
(sendEmail == 1)
{
string
userName = User.Identity.Name.ToString();
string
[] tokens = userName.Split(
'\\'
);
ApplicationUserBO current_user =
new
ApplicationUserBO();
//current_user.FillByUserID(parent.UserID);
current_user.FillByUserID(7);
string
body = tokens[1].ToString() +
" has completed "
+ client.client_name +
"'s PE report for "
+ updated_close.report_dated.ToShortDateString();
string
subject = client.client_name +
" PE Report Completed"
;
string
to = current_user.e_mail.ToString();
string
from =
"PERA@haifc.com"
;
Session.Add(
"from"
, from);
Session.Add(
"to"
, to);
Session.Add(
"subject"
, subject);
Session.Add(
"body"
, body);
ScriptManager.RegisterStartupScript(
this
,
this
.GetType(),
"mykey"
,
"radconfirm('Would you like to notify "
+ client.client_name +
"'s"
+
" PA?', confirmCallBackFn, 330, 100, null,'Send Message?');"
,
true
);
//RadAjaxManager1.ResponseScripts.Add("radconfirm('Would you like to notify " + client.client_name + "'s" + " PA?', confirmCallBackFn, 330, 100, null,'Send Message?');");
//ClientScriptManager cs = Page.ClientScript;
//cs.RegisterClientScriptBlock(this.GetType(), "popupScript", RadWindowManager1.ClientID + ".radconfirm('Would you like to notify " + client.client_name + "'s" + " PA?', confirmCallBackFn, 330, 100, null,'Send Message?');", true);
//ClientScript.RegisterStartupScript(Page.GetType(), "popupScript", "radconfirm('Would you like to notify " + client.client_name + "'s" + " PA?', confirmCallBackFn, 330, 100, null,'Send Message?');", true);
}
}
}
catch
(Exception exe)
{
error_ind =
true
;
//MessageBox.Show(exe.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//logger.RecordMessage(exe, Log.MessageType.Error, parent.UserID);
}
}
}
catch
(Exception ex)
{
ReportGrid.Controls.Add(
new
LiteralControl(
"Unable to update. Reason: "
+ ex.Message));
//logger.RecordMessage(exe, Log.MessageType.Error, parent.UserID);
e.Canceled =
true
;
}
}
}
<
telerik:GridDropDownColumn
DataField
=
"Status_ID"
DataSourceID
=
"SqlDataSource_WTGTasksStatus"
HeaderText
=
"Status"
ListTextField
=
"Status_Text"
ListValueField
=
"Status_ID"
UniqueName
=
"Status_ID"
ColumnEditorID
=
"StatusDropdownEditor"
>
Here is my Column Editor:
<
telerik:GridDropDownListColumnEditor
ID
=
"StatusDropdownEditor"
DropDownStyle-Width
=
"75px"
runat
=
"server"
/>
<
asp:SqlDataSource
ID
=
"SqlDataSource_WTGTasksStatus"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ParkAnalyticsConnectionString %>"
SelectCommand="SELECT [Status_ID], [Status_Text] FROM [WTGTasksStatus]">
</
asp:SqlDataSource
>