I have a web page that shows a parameters grid for each parameter group.
To achieve this result I want to use an asp Repeater. I can see the grid correctly but the radGrid update seems not to work. I think the grid cannot find the datasource at the update event.
This is the part on my page:
<table width="100%;"> |
<tr> |
<td> |
<div style="width: 7cm;"> |
</div> |
</td> |
<td style="text-align: right;"> |
<asp:Label ID="LabelGruppo" runat="server" Text="Label"></asp:Label> |
<telerik:RadComboBox ID="RadComboBoxGruppo" runat="server" DataSourceID="ObjectDataSourceGruppiParametriComboBox" |
DataTextField="NomeGruppo" DataValueField="IdGruppo" AutoPostBack="True" |
AppendDataBoundItems="True"> |
<Items> |
<telerik:RadComboBoxItem runat="server" Text="---" Value="-1" /> |
</Items> |
</telerik:RadComboBox> |
<asp:ObjectDataSource ID="ObjectDataSourceGruppiParametriComboBox" |
runat="server" SelectMethod="getAll" |
TypeName="MachinaWeb.Services.BO_ConfigurazioneProgramma_GruppoParametri"> |
<SelectParameters> |
<asp:ControlParameter ControlID="HiddenFieldIdCultura" Name="_idCultura" |
PropertyName="Value" Type="Int64" /> |
</SelectParameters> |
</asp:ObjectDataSource> |
</td> |
</tr> |
</table> |
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSourceGruppiParametri" |
OnItemDataBound="ParentRepeater_ItemDataBound"> |
<HeaderTemplate> |
</HeaderTemplate> |
<FooterTemplate> |
</FooterTemplate> |
<ItemTemplate> |
<div id="IntestazioneGruppo" style="background-color: Orange; border: 1px solid black; |
text-align: center; margin-bottom: 11px;"> |
<%# Eval("NomeGruppo") %></div> |
</b> |
<telerik:RadGrid ID="RadGridParametriConfigurazione" runat="server" EnableEmbeddedSkins="False" |
GridLines="None" Skin="MachinaWeb" AllowPaging="true" PageSize="15" AllowAutomaticUpdates="true"> |
<ClientSettings> |
<Selecting EnableDragToSelectRows="False" AllowRowSelect="True" /> |
</ClientSettings> |
<MasterTableView AutoGenerateColumns="False"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridEditCommandColumn ButtonType="ImageButton" CancelImageUrl="~/Images/ImagesGrid/Cancel.gif" |
EditImageUrl="~/Images/ImagesGrid/Edit.gif" UpdateImageUrl="~/Images/ImagesGrid/Update.gif" |
InsertImageUrl="~/Images/ImagesGrid/Update.gif" UniqueName="EditCommandColumn" ItemStyle-Width="40px" /> |
<telerik:GridBoundColumn DataField="IdParametro" DataType="System.Int64" HeaderText="IdParametro" |
SortExpression="IdParametro" UniqueName="IdParametro" Visible="false"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="IdCultura" DataType="System.Int64" HeaderText="IdCultura" |
SortExpression="IdCultura" UniqueName="IdCultura" Visible="false"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="DescrizioneParametro" HeaderText="DescrizioneParametro" |
SortExpression="DescrizioneParametro" UniqueName="DescrizioneParametro"> |
</telerik:GridBoundColumn> |
</Columns> |
<EditFormSettings> |
<EditColumn> |
</EditColumn> |
</EditFormSettings> |
</MasterTableView> |
</telerik:RadGrid> |
<asp:ObjectDataSource ID="ObjectDataSourceParametri" runat="server" SelectMethod="getAll" |
TypeName="MachinaWeb.Services.BO_ConfigurazioneProgramma_Parametro"> |
<SelectParameters> |
<asp:Parameter Name="_idGruppoParametro" Type="Int64" /> |
<asp:ControlParameter ControlID="HiddenFieldIdCultura" Name="_idCultura" PropertyName="Value" |
Type="Int64" /> |
</SelectParameters> |
</asp:ObjectDataSource> |
<asp:HiddenField ID="HiddenFieldIdGruppo" runat="server" Value='<%# DataBinder.Eval(Container.DataItem,"IdGruppo")%>' /> |
</ItemTemplate> |
<SeparatorTemplate> |
<%----- fine gruppo -----%> |
<div style="margin-bottom: 20px;"> |
</div> |
</SeparatorTemplate> |
</asp:Repeater> |
<asp:ObjectDataSource ID="ObjectDataSourceGruppiParametri" runat="server" SelectMethod="getAll" |
TypeName="MachinaWeb.Services.BO_ConfigurazioneProgramma_GruppoParametri"> |
<SelectParameters> |
<asp:ControlParameter ControlID="HiddenFieldIdCultura" Name="_idCultura" PropertyName="Value" |
Type="Int64" /> |
<asp:ControlParameter ControlID="RadComboBoxGruppo" Name="_idGruppoSelezionato" PropertyName="SelectedValue" |
Type="Int64" /> |
</SelectParameters> |
</asp:ObjectDataSource> |
<asp:HiddenField ID="HiddenFieldIdCultura" runat="server" /> |
And this is code:
protected void Page_Load(object sender, EventArgs e) |
{ |
HiddenFieldIdCultura.Value = ((SessionInformation)Session["sessionData"]).IdCultura.ToString(); |
BO_Azienda bo_azienda = new BO_Azienda(((SessionInformation)Session["sessionData"]).IdAzienda); |
LabelNomeAzienda.Text = bo_azienda.NomeAzienda; |
LabelIntestazioneAzienda.Text = bo_azienda.Intestazione; |
} |
protected void ParentRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) |
{ |
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) |
{ |
RadGrid radGrid = (RadGrid)e.Item.FindControl("RadGridParametriConfigurazione"); |
ObjectDataSource ObjectDataSourceParametri = (ObjectDataSource)e.Item.FindControl("ObjectDataSourceParametri"); |
ObjectDataSourceParametri.SelectParameters["_idGruppoParametro"].DefaultValue = ((HiddenField)e.Item.FindControl("HiddenFieldIdGruppo")).Value; |
radGrid.DataSource = ObjectDataSourceParametri; |
radGrid.DataBind(); |
} |
} |