Hi,
I've got this page with a couple of RadComboBoxes, an asp TextBox, a RadCalendar, a RadGrid and 2 asp Buttons (Submit and Cancel). The idea is that the user can select categories from the comboboxes, enter a value in the textbox, select a date and press Submit to store the data and it will be shown in the radgrid below (together with older entries, based on the date selected in the calendar).
However, for some reason I can't get the RadGrid to update on the client. The data is stored and everything but it simply won't show. Refreshing the page _does_ update it, but so does pressing a button again (such as edit, submit, or even changing the date on the calendar). What am I doing wrong?
I have the same problem with the Delete button, although the entry does get deleted, it is not reflected on the client.
My ASCX file:
My CS file:
Do note that the triple periods (...) in the code mean I omitted some code there for readability.
Any help would be appreciated,
- Dennis
EDIT: In case you're wondering: the dropdownlist UpdateDataBind functions simply set the DataTextField, DataValueField, assign a new DataSet to DataSource and trigger the DataBind function.
I've got this page with a couple of RadComboBoxes, an asp TextBox, a RadCalendar, a RadGrid and 2 asp Buttons (Submit and Cancel). The idea is that the user can select categories from the comboboxes, enter a value in the textbox, select a date and press Submit to store the data and it will be shown in the radgrid below (together with older entries, based on the date selected in the calendar).
However, for some reason I can't get the RadGrid to update on the client. The data is stored and everything but it simply won't show. Refreshing the page _does_ update it, but so does pressing a button again (such as edit, submit, or even changing the date on the calendar). What am I doing wrong?
I have the same problem with the Delete button, although the entry does get deleted, it is not reflected on the client.
My ASCX file:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucTimesheet.ascx.cs" Inherits="PRIS.Timesheet.ucTimesheet" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
...
<
telerik:RadAjaxManagerProxy
ID
=
"ramAjaxManager"
runat
=
"server"
>
<
AjaxSettings
>
...
<
telerik:AjaxSetting
AjaxControlID
=
"rdgTimeList"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"rdgTimeList"
LoadingPanelID
=
"pnlListLoading"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
...
<
telerik:AjaxSetting
AjaxControlID
=
"btnSubmit"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlTimeSheet"
LoadingPanelID
=
"pnlListLoading"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlForm"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnCancel"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlTimeSheet"
LoadingPanelID
=
"pnlListLoading"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlForm"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManagerProxy
>
<
asp:Panel
runat
=
"server"
ID
=
"pnlForm"
>
...
<
asp:Button
ID
=
"btnSubmit"
runat
=
"server"
Text
=
"Boek"
CssClass
=
"Button_Pris"
TabIndex
=
"6"
OnClick
=
"btnSubmit_Click"
/>
...
<
asp:Button
ID
=
"btnCancel"
runat
=
"server"
Text
=
"Cancel"
CssClass
=
"Button_Pris"
TabIndex
=
"7"
OnClick
=
"btnCancel_Click"
/>
...
</
asp:Panel
>
<
asp:Panel
runat
=
"server"
ID
=
"pnlTimeSheet"
>
<
telerik:RadGrid
ID
=
"rdgTimeList"
runat
=
"server"
AutoGenerateColumns
=
"false"
OnNeedDataSource
=
"rdgTimeList_NeedDataSource"
OnItemDataBound
=
"rdgTimeList_ItemDataBound"
OnItemCreated
=
"rdgTimeList_ItemCreated"
ShowFooter
=
"true"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridTemplateColumn
>
<
HeaderStyle
Width
=
"22px"
/>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"btnEdit"
runat
=
"server"
ImageUrl
=
"~/DesktopModules/PRIS.Common/Images/icn_pencil.gif"
OnCommand
=
"btnEdit_Click"
CommandName
=
"id"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "pkid").ToString()%>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
HeaderStyle
Width
=
"22px"
/>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"btnDelete"
runat
=
"server"
ImageUrl
=
"~/DesktopModules/PRIS.Common/Images/icn_delete.gif"
OnCommand
=
"btnDelete_Click"
CommandName
=
"id"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "pkid").ToString()%>' OnClientClick="if(!confirm('Weet u het zeker?')){return false;}" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
...
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
...
</
asp:Panel
>
My CS file:
protected
void
rdgTimeList_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
...
int
liEmployeeId = (!String.IsNullOrEmpty(ddlEmployee.SelectedValue)) ? Convert.ToInt32(ddlEmployee.SelectedValue) : -1;
rdgTimeList.DataSource = PRIS.SP.SpCacheUrenVanMedewerker(liEmployeeId, StartDate, EndDate, MaatschappijId).GetDataSet();
...
}
protected
void
btnSubmit_Click(
object
sender, EventArgs e)
{
SaveForm();
rdgTimeList.Rebind();
}
protected
void
btnCancel_Click(
object
sender, EventArgs e)
{
ClearForm();
}
protected
void
SaveForm()
{
...
PAtblUur loUur =
null
;
string
lsProject = ddlProject.SelectedValue;
string
lsDeliverable = ddlDeliverable.SelectedValue;
string
lsActivity = ddlActivity.SelectedValue;
bool
saved =
false
;
if
(objCalendar.SelectedDates.Count == 1)
{
loUur = TimeObject;
loUur.CBMaatschappijID = MaatschappijId;
loUur.FKActiviteitID =
this
.SaveActivity();
loUur.FKPersoonRelatieID = (!String.IsNullOrEmpty(ddlEmployee.SelectedValue)) ? Convert.ToInt16(ddlEmployee.SelectedValue) : -1;
loUur.DatumBezetting = objCalendar.SelectedDates[0].Date;
loUur.UrenBesteed = (!String.IsNullOrEmpty(txtHours.Text)) ? Convert.ToDecimal(txtHours.Text) : 0;
try
{
loUur.Save();
saved =
true
;
}
catch
{
ErrorManager.Errors = loUur.Errors;
ErrorManager.LoadErrors();
}
}
else
{
...
}
if
(saved)
{
ClearForm(
false
);
}
...
}
private
void
ClearForm() { ClearForm(
true
); }
private
void
ClearForm(
bool
pbClearDate)
{
// Clear message label
lblMessage.Text =
""
;
// Get the current user's id
int
liEmployeeId = (!String.IsNullOrEmpty(ddlEmployee.SelectedValue)) ? Convert.ToInt32(ddlEmployee.SelectedValue) : -1;
// Reload Employee combobox
ddlEmployee_UpdateDataBind(liEmployeeId);
// Reload Project combobox
ddlProject_UpdateDataBind(liEmployeeId);
// Clear Deliverable combobox
ddlDeliverable.Text =
""
;
ddlDeliverable.Items.Clear();
ddlDeliverable.SelectedValue =
""
;
ddlDeliverable.SelectedIndex = 0;
// Clear Activity combobox
ddlActivity.Text =
""
;
ddlActivity.Items.Clear();
ddlActivity.SelectedValue =
""
;
ddlActivity.SelectedIndex = 0;
// Clear Hours textbox
txtHours.Text =
""
;
hfTimeId.Value =
"-1"
;
// Clear the selected dates
if
(pbClearDate)
{
objCalendar.SelectedDates.Clear();
objCalendar.SelectedDate = System.DateTime.Now;
}
// Rebind RadGrid
rdgTimeList.Rebind();
if
(ErrorManager.Errors.Count == 0)
{
ErrorManager.HideErrors();
}
}
Do note that the triple periods (...) in the code mean I omitted some code there for readability.
Any help would be appreciated,
- Dennis
EDIT: In case you're wondering: the dropdownlist UpdateDataBind functions simply set the DataTextField, DataValueField, assign a new DataSet to DataSource and trigger the DataBind function.