RadGridCardDetails.MasterTableView.FindItemByKeyValue("CardDetailsID", new Guid(HiddenShowCardDetailID.Value)).Edit = true;
RadGridCardDetails.Rebind();
14 Answers, 1 is accepted


Give a try with following approach and see whether it helps.
CS:
bool check = false; |
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
if (!check) |
{ |
RadGrid1.MasterTableView.Items[0].Edit = true; // Put the corresponding row in editmode (initially) |
RadGrid1.MasterTableView.Rebind(); |
} |
} |
protected void Button2_Click(object sender, EventArgs e) |
{ |
check = true; |
RadGrid1.MasterTableView.IsItemInserted = false; |
RadGrid1.MasterTableView.ClearEditItems(); |
} |
-Shinu.

My grid:
<telerik:RadGrid runat="server" ID="RadGridCardDetails" EnableViewState="true" AutoGenerateColumns="False" |
ShowStatusBar="true" Skin="Vista" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" |
AllowAutomaticUpdates="True" OnNeedDataSource="RadGridCardDetails_NeedDataSource" |
AllowPaging="True" AllowSorting="True" HorizontalAlign="NotSet" GridLines="None" |
OnItemCommand="RadGridCardDetails_ItemCommand" OnUpdateCommand="RadGridCardDetails_UpdateCommand" |
OnInsertCommand="RadGridCardDetails_InsertCommand" OnDeleteCommand="RadGridCardDetails_DeleteCommand" |
OnItemDataBound="RadGridCardDetails_ItemDataBound" OnItemCreated="RadGridCardDetails_ItemCreated" |
OnPreRender="RadGridCardDetails_PreRender"> |
<PagerStyle Mode="NextPrevAndNumeric" /> |
<asp:Button ID="btnUpdate" OnClientClick="setValueIsUpdate()" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' |
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' |
CausesValidation="True" ValidationGroup="ValidationTextField"></asp:Button> |
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel"></asp:Button> |
</FormTemplate> |
<PopUpSettings ScrollBars="None" /> |
</EditFormSettings> |
</MasterTableView> |
</telerik:RadGrid> |
editFormItem.Display = false; and e.Canceled = true; don't work. in my protected void RadGridCardDetails_UpdateCommand(object source, GridCommandEventArgs e) event.

If you are performing manual insert and update operations, then you should not be setting the AllowAutomaticInserts/AllowAutomaticUpdates to true which is why the forms do not close on hitting the update or insert buttons. Also the automatic operations work only when binding the grid to a declarative data source using the DataSourceID property of the grid. Hence, try setting the AllowAutomaticInserts/AllowAutomaticUpdates properties of the grid to false and see if it helps.
Thanks
Princy.

RadGridCardDetails.EditIndexes.Clear();

Try the following code and see if it helps to close the pop up on insert:
c#:
RadGridCardDetails.MasterTableView.IsItemInserted = false; |
RadGridCardDetails.MasterTableView.Rebind(); |
Thanks
Princy.

Here is my prerender for anyone else :
protected void RadGridCardDetails_PreRender(object sender, EventArgs e) |
{ |
if (Session["ItemInserted"] != null && Session["ItemInserted"] == "True") |
{ |
RadGridCardDetails.EditIndexes.Clear(); |
RadGridCardDetails.MasterTableView.IsItemInserted = false; |
RadGridCardDetails.MasterTableView.Rebind(); |
} |
} |


Hi all,
How can I pass the properties to edit form user control.
I am not quite sure about your requirement. I suppose you want to access the usercontrol in radgrid. Here is the sample code.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
LinkButton link = (LinkButton)userControl.FindControl(
"LinkButton1"
);
//accessing the controls in usercontrol
string
value = item.GetDataKeyValue(
"EmployeeID"
).ToString();
//accessing datakeynames
}
}
Thanks,
Shinu.

Thanks for replay ...
i am doing the same way but nothing happens ....
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
userControl
getting null value ...can you please send any example ....

How to handle the postback within the user control when rad grid is edit for mode..... also i want to use the user control event to Update the record and some operation on user control .... please send any example or site reference ...........

I am not quite sure about your requirement. You can add a usercontrol in EditformSettings as shown below and get a reference to the controls using the following code.
aspx:
<
EditFormSettings
UserControlName
=
"UserControl.ascx"
EditFormType
=
"WebUserControl"
>
</
EditFormSettings
>
protected
void
RadGrid1_UpdateCommand(
object
source, GridCommandEventArgs e)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
LinkButton link = (LinkButton)userControl.FindControl(
"LinkButton1"
);
}
Thanks,
Shinu.

Hi shinu ,
Thanks for replay
My scenario is – I have one user control with rad grid and and I want to use rad grid edit form functionality to add various user control to rad grid edit form.
I am able to do this ….
But I want to use the event’s in user control or perform some operation in use control according user controls event. for example I want to check duplicate data entry in rad grid edit user control and show duplicate entry message to user , I am able to check the duplicate entry of data but ,I am using rad grid ItemDatabound to bind data to user control for this reason after the postback it show the old data, and my edit for user control is close. Is there any way to handle the events in user control with rad grid itemdataboud or any other way to handle user control event …………