While RadGridEmpData.EditIndexes.Count > 0
RadGridEmpData.EditIndexes.Clear()
RadGridEmpData.Rebind()
End While
but the EditIndexes.count is always zero. Can I refresh the radgrid even if there is a row in edit mode? If not, then how can I clear any rows in edit mode in the rad grid?
Thanks!
Suresh
3 Answers, 1 is accepted
You should be able to both clear any edited rows with the approach you have been using, as well as rebind the grid no matter if there are any edited rows or not. Posting any more details along with some sample code may help us identify what's wrong.
All the best,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
After insert values Edit mode not hiding
<telerik:RadGrid ID="grdOnboardComments" GridLines="Both" AutoGenerateColumns="false" OnItemCreated ="grdOnboardComments_ItemCreated"
OnItemDataBound="grdOnboardComments_ItemDataBound" OnNeedDataSource="grdOnboard_NeedDataSource"
OnItemCommand="grdOnboardComments_ItemCommand" runat="server" Height="170px">
<HeaderStyle CssClass="RadGridHeader"></HeaderStyle>
<MasterTableView TableLayout="Fixed" Width="100%" CommandItemDisplay="Bottom" EditMode="InPlace"
NoMasterRecordsText="No records found.">
<CommandItemSettings AddNewRecordText="Add Comments" />
<Columns>
<telerik:GridTemplateColumn UniqueName="Task" HeaderText="Task" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="lblCommentsTask" runat="server" Text='<%# Bind("TASK_NAME") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="rcbTask" runat="server" CssClass="clsEditField" AllowCustomText="false"
MarkFirstMatch="true" Width="195px" Height="150px">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Status" HeaderText="Status" HeaderStyle-Width="40px">
<ItemTemplate>
<asp:Label ID="lblCommentsStatus" runat="server" Text='<%# Bind("status_text") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="rcbCommentsStatus" runat="server" RenderMode="Lightweight"
CssClass="clsEditField" AllowCustomText="false" MarkFirstMatch="true" Width="100px"
Height="85px">
<Items>
<telerik:RadComboBoxItem runat="server" Text="Completed" Value="1" />
<telerik:RadComboBoxItem runat="server" Text="In Progress" Value="2" />
</Items>
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Date_Added" HeaderText="Date Added" HeaderStyle-Width="40px">
<ItemTemplate>
<asp:Label ID="lblDateAdded" runat="server" Text='<%# Bind("Date_Added") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadDatePicker Width="100px" ID="txtDate_Added" runat="server">
</telerik:RadDatePicker>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Commented_By" HeaderText="Comments By" HeaderStyle-Width="40px">
<ItemTemplate>
<asp:Label ID="lblUserName" runat="server" Text='<%# Bind("User_Name") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox ID="txtUserName" Width="100px" runat="server">
</telerik:RadTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Comments" HeaderText="Comments" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:Label ID="lblComments" runat="server" Text='<%# Bind("Comments") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox ID="txtComments" Width="100px" Text='<%# Bind("Date_Added") %>' runat="server">
</telerik:RadTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderStyle-Width="40px" UniqueName="Actions" HeaderText="Actions"
Display="true">
<EditItemTemplate>
<telerik:RadButton ID="btnCommentSave" runat="server" Text="Save" CommandName="SaveComments">
</telerik:RadButton>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings Resizing-AllowColumnResize="true" Scrolling-AllowScroll="true" >
</ClientSettings>
</telerik:RadGrid>
c#:
protected void grdOnboardComments_ItemCommand(object sender, GridCommandEventArgs e)
{
try
{
if ((e.CommandName == "SaveComments"))
{
CaseOnboardCommentsVO caseComments = new CaseOnboardCommentsVO();
GridDataItem item = (GridDataItem)e.Item;
Decimal _task_id = 0;
caseComments.Case_Master_Id = case_id;
_task_id = Convert.ToDecimal((item.FindControl("rcbTask") as RadComboBox).SelectedValue);
caseComments.TASK_ID = _task_id;
caseComments.Status = Convert.ToInt32((item.FindControl("rcbCommentsStatus") as RadComboBox).SelectedValue);
caseComments.Date_Added = (item.FindControl("txtDate_Added") as RadDatePicker).SelectedDate;
caseComments.User_Name = (item.FindControl("txtUserName") as RadTextBox).Text; // modify this hard code to GetCurrentUser().login_id;
caseComments.Comments = (item.FindControl("txtComments") as RadTextBox).Text;
caseOnboardList = new CaseOnboardVO();
caseOnboardList.caseOnboardCommentsVO.Add(caseComments);
this.CDHServiceAgent.storeCaseOnboard(caseOnboardList);
grdOnboardComments.MasterTableView.ClearEditItems();
grdOnboardComments.Rebind();
e.Canceled = true;
}
}
Please hele me on this
Best Regards
Raghu Kiran
Please try removing the e.Canceled = true; line from the code-behind logic.
This should resolve the issue.
Regards,
Eyup
Telerik