3 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 10 Nov 2010, 04:53 AM
Hello John,
In order to achieve this, you can use FireCommandEvent method as described in the following documentation.
How to fire command events from code
Thanks,
Princy.
In order to achieve this, you can use FireCommandEvent method as described in the following documentation.
How to fire command events from code
Thanks,
Princy.
0
John
Top achievements
Rank 1
answered on 10 Nov 2010, 10:04 AM
Hi,
thanks but I still cannot get this to work, let me try and explain what I'm trying to do in some more detail.
My RadGrid has a modal popup used to add new records, this is shown below. What I want to do is get this modal popup to be triggered by a new Method, in this case called AddNew in the code behind.
EditForm markup
Code behind calling mathod
thanks but I still cannot get this to work, let me try and explain what I'm trying to do in some more detail.
My RadGrid has a modal popup used to add new records, this is shown below. What I want to do is get this modal popup to be triggered by a new Method, in this case called AddNew in the code behind.
EditForm markup
<
EditFormSettings
InsertCaption
=
"Add Note"
CaptionFormatString
=
"View Note"
EditFormType
=
"Template"
>
<
PopUpSettings
Modal
=
"true"
/>
<
FormTemplate
>
<
table
id
=
"tblAddNote"
cellspacing
=
"1"
cellpadding
=
"1"
width
=
"250px"
border
=
"0"
>
<
tr
>
<
td
>
<
asp:TextBox
ReadOnly='<%# !(Container is GridEditFormInsertItem) %>' Width="400px" Height="150px" TextMode="MultiLine" ID="txtNote" Text='<%# Bind( "Content") %>' runat="server">
</
asp:TextBox
>
</
td
>
</
tr
>
</
table
>
<
table
style
=
"width: 100%"
>
<
tr
>
<
td
align
=
"right"
colspan
=
"2"
>
<
asp:Button
ID
=
"btnUpdate"
Text='<%# (Container is GridEditFormInsertItem) ? "Add" : "Close" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Cancel" %>'>
</
asp:Button
>
<
asp:Button
ID
=
"btnCancel"
Visible="<%# (Container is GridEditFormInsertItem) %>" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">
</
asp:Button
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
</
EditFormSettings
>
Code behind calling mathod
protected
void
RadGrid_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.Item
is
GridCommandItem && e.CommandName ==
"InitInsert"
)
{
RadGrid.MasterTableView.NoMasterRecordsText =
string
.Empty;
}
}
public
void
AddNew()
{
GridCommandItem GCI =
new
GridCommandItem(RadGrid.MasterTableView);
RadGrid.MasterTableView.NoMasterRecordsText =
string
.Empty;
//RadGrid.RaisePostBackEvent(string.Empty);
GCI.FireCommandEvent(
"InitInsert"
, String.Empty);
}
0
Princy
Top achievements
Rank 2
answered on 11 Nov 2010, 11:41 AM
Hello John,
Try the following approach to access GridCommandItem and check whether it works now.
C#:
Thanks,
Princy.
Try the following approach to access GridCommandItem and check whether it works now.
C#:
public
void
AddNew()
{
GridCommandItem GCI = (GridCommandItem)RadGrid.MasterTableView.GetItems(GridItemType.CommandItem)[0];
GCI.FireCommandEvent(
"InitInsert"
, String.Empty);
}
Thanks,
Princy.