Hello,
I have 4 RadGrids in editmode in my content page and they are in a multipageview. My problem is when I want to update all my grids. They are in my content page and i've made a button to update the grids in the masterpage. Is there a way to access the values of the grids in my content page from the masterpage or to call the update commande of the radgrids from the masterpage.
Thanks
Keven
I have 4 RadGrids in editmode in my content page and they are in a multipageview. My problem is when I want to update all my grids. They are in my content page and i've made a button to update the grids in the masterpage. Is there a way to access the values of the grids in my content page from the masterpage or to call the update commande of the radgrids from the masterpage.
Thanks
Keven
4 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 13 Dec 2010, 02:05 PM
Hello Keven,
Following is a sample code to achieve your requirement. Inside 'OnClick' event of button in MasterPage, access the ContentPalceholder first and then using FindControl method get each control like below.
ASPX: (content page)
C#: (master page)
-Shinu.
Following is a sample code to achieve your requirement. Inside 'OnClick' event of button in MasterPage, access the ContentPalceholder first and then using FindControl method get each control like below.
ASPX: (content page)
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"Server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
telerik:RadMultiPage
ID
=
"RadMultiPage1"
runat
=
"server"
SelectedIndex
=
"0"
>
<
telerik:RadPageView
ID
=
"Pageview1"
runat
=
"server"
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowMultiRowEdit
=
"true"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
EditMode
=
"InPlace"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"EmployeeID"
DataField
=
"EmployeeID"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
telerik:RadPageView
>
</
telerik:RadMultiPage
>
</
asp:Content
>
C#: (master page)
protected
void
Button1_Click(
object
sender, EventArgs e)
{
ContentPlaceHolder contentPlaceHolder = (ContentPlaceHolder)
this
.FindControl(
"ContentPlaceHolder1"
);
// accessing ContentPlaceHolder
RadMultiPage multiPage = (RadMultiPage)contentPlaceHolder.FindControl(
"RadMultiPage1"
);
// accessing MultiPage
RadGrid RadGrid1 = (RadGrid)multiPage.PageViews[0].FindControl(
"RadGrid1"
);
//accessing RadGrid
foreach
(GridDataItem item
in
RadGrid1.Items)
//loops through each grid item
{
if
(item
is
GridEditableItem)
{
TextBox txtbox = (TextBox)item[
"EmployeeID"
].Controls[0];
string
value = txtbox.Text;
}
}
}
-Shinu.
0

Keven
Top achievements
Rank 1
answered on 13 Dec 2010, 03:03 PM
Thanks for the quick reply Shinu, but unfortunately it doesn't work. It's always giving me a argument of out range exception error on item("itemname").controls(0). The difference with your example is that I don't use a inplace editmode but a editforms.
Thanks
Keven
Dim
temp_multi_page
As
RadMultiPage =
Me
.ContentPlaceHolder1.FindControl(
"RadMultipage1"
)
Dim
grid_serveur
As
RadGrid = temp_multi_page.FindControl(
"RadGridServeur"
)
For
Each
item
In
grid_serveur.Items
If
TypeOf
item
Is
GridEditableItem
Then
Dim
txtbox
As
TextBox =
DirectCast
(item(
"NOM"
).Controls(0), TextBox)
Dim
value
As
String
= txtbox.Text
End
If
Next
<
telerik:RadMultiPage
ID
=
"RadMultiPage1"
Runat
=
"server"
Height
=
"500px"
SelectedIndex
=
"0"
Width
=
"100%"
>
<
telerik:RadPageView
ID
=
"RadPageViewServeur"
runat
=
"server"
Height
=
"380px"
>
<
telerik:RadGrid
ID
=
"RadGridServeur"
runat
=
"server"
AllowAutomaticUpdates
=
"True"
AutoGenerateColumns
=
"False"
Skin
=
"Black"
AllowMultiRowEdit
=
"true"
>
<
MasterTableView
DataKeyNames
=
"NO_SERVEUR"
CommandItemDisplay
=
"None"
EditMode
=
"EditForms"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"NO_SERVEUR"
ReadOnly
=
"true"
SortExpression
=
"NO_SERVEUR"
UniqueName
=
"NO_SERVEUR"
display
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"NOM"
HeaderText
=
"Nom"
SortExpression
=
"NOM"
UniqueName
=
"NOM"
display
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SERVICE"
HeaderText
=
"Service"
SortExpression
=
"SERVICE"
UniqueName
=
"SERVICE"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"UTILISATION"
HeaderText
=
"Utilisation"
SortExpression
=
"UTILISATION"
UniqueName
=
"UTILISATION"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"PERMANENT_TEST"
HeaderText
=
"Serveur permanent ou test"
SortExpression
=
"PERMANENT_TEST"
UniqueName
=
"PERMANENT_TEST"
visible
=
"false"
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"LabelPermanentTest"
runat
=
"server"
Text='<%# eval("PERMANENT_TEST") %>' Visible="false"></
asp:Label
>
<
asp:RadioButtonList
ID
=
"RadioButtonPermanentTest"
runat
=
"server"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"DUREE_TEST"
HeaderText
=
"Duree de vie ou du test"
SortExpression
=
"DUREE_TEST"
UniqueName
=
"DUREE_TEST"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"LOCALISATION"
HeaderText
=
"Localisation"
SortExpression
=
"LOCALISATION"
UniqueName
=
"LOCALISATION"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"RPO"
HeaderText
=
"RPO"
SortExpression
=
"RPO"
UniqueName
=
"RPO"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"RTO"
HeaderText
=
"RTO"
SortExpression
=
"RTO"
UniqueName
=
"RTO"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"RESPONSABLE"
HeaderText
=
"Responsable"
SortExpression
=
"RESPONSABLE"
UniqueName
=
"RESPONSABLE"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CLIENTELE"
HeaderText
=
"Clientèle"
SortExpression
=
"CLIENTELE"
UniqueName
=
"CLIENTELE"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
DataField
=
"SERVEUR_MICROSOFT"
HeaderText
=
"Serveur Microsoft"
SortExpression
=
"SERVEUR_MICROSOFT"
UniqueName
=
"SERVEUR_MICROSOFT"
visible
=
"false"
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"LabelServeurMicrosoft"
runat
=
"server"
Text='<%# eval("SERVEUR_MICROSOFT") %>' Visible="false"></
asp:Label
>
<
asp:RadioButtonList
ID
=
"RadioButtonServeurMicrosoft"
runat
=
"server"
AutoPostBack
=
"true"
OnSelectedIndexChanged
=
"VerifServeurMicrosoft"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
DataField
=
"CAL"
HeaderText
=
"CAL"
SortExpression
=
"CAL"
UniqueName
=
"CAL"
visible
=
"false"
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"LabelCAL"
runat
=
"server"
Text='<%# eval("CAL") %>' Visible="false"></
asp:Label
>
<
asp:RadioButtonList
ID
=
"RadioButtonCAL"
runat
=
"server"
/>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"DATE_CREATION"
HeaderText
=
"Date de création"
SortExpression
=
"DATE_CREATION"
UniqueName
=
"DATE_CREATION"
visible
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
</
telerik:RadPageView
>
</
telerik:RadMultiPage
>
Thanks
Keven
0
Accepted

Shinu
Top achievements
Rank 2
answered on 14 Dec 2010, 07:57 AM
Hello Keven,
Please make the following modification in the above code if you are using RadGrid EditMode as 'EditForms'.
VB.NET:
-Shinu.
Please make the following modification in the above code if you are using RadGrid EditMode as 'EditForms'.
VB.NET:
Protected
Sub
Button1_Click(sender
As
Object
, e
As
EventArgs)
Dim
contentPlaceHolder
As
ContentPlaceHolder =
DirectCast
(
Me
.FindControl(
"ContentPlaceHolder1"
), ContentPlaceHolder)
Dim
multiPage
As
RadMultiPage =
DirectCast
(contentPlaceHolder.FindControl(
"RadMultiPage1"
), RadMultiPage)
Dim
RadGrid1
As
RadGrid =
DirectCast
(multiPage.PageViews(0).FindControl(
"RadGrid1"
), RadGrid)
For
Each
editItem
As
GridEditFormItem
In
RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)
Dim
txtbox
As
TextBox =
DirectCast
(editItem(
"EmployeeID"
).Controls(0), TextBox)
Dim
value
As
String
= txtbox.Text
Next
End
Sub
-Shinu.
0

Keven
Top achievements
Rank 1
answered on 14 Dec 2010, 02:32 PM
You're the best Shinu ! Thanks a lot !
Your solution work perfectly.
Your solution work perfectly.