Hello together,
as this is my first post on this forums and am new to telerik components, please be gentle, if this is a dumb question. ;-)
I try to use two RadGrids which are linked together:
AllowPaging="True" AllowAutomaticUpdates="False" AllowAutomaticInserts="False"
AllowAutomaticDeletes="False" AllowSorting="true"
DataSourceID="Companies">
<MasterTableView AutoGenerateColumns="False"
DataKeyNames="CompanyId">
<Columns>
<telerik:GridBoundColumn DataField="CompanyId" HeaderText="Nr." SortExpression="CompanyId"
UniqueName="CompanyId" Visible="true" ReadOnly="true" MaxLength="5">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CompanyName" HeaderText="Unternehmensname" SortExpression="CompanyName"
UniqueName="CompanyName" Visible="true" ItemStyle-Width="150" DataFormatString="{0}" ReadOnly="true">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
<Selecting AllowRowSelect="true"></Selecting>
</ClientSettings>
</telerik:RadGrid>
and
and the DataSources:
But now I have a problem. When I try to add a new product in the second grid, it doesn't get the correct value for the value "CompanyId" in "Products". But it is needed, as it is a foreign key.
I'm quite stuck with this and I'm sure, the solution is quite simple. But nothing I tried yet, worked in any way.
So I would appreciate, if someone can help me out with this.
Yours
Aljoscha
as this is my first post on this forums and am new to telerik components, please be gentle, if this is a dumb question. ;-)
I try to use two RadGrids which are linked together:
<telerik:RadGrid ID="rgCompanies" runat="server"AllowPaging="True" AllowAutomaticUpdates="False" AllowAutomaticInserts="False"
AllowAutomaticDeletes="False" AllowSorting="true"
DataSourceID="Companies">
<MasterTableView AutoGenerateColumns="False"
DataKeyNames="CompanyId">
<Columns>
<telerik:GridBoundColumn DataField="CompanyId" HeaderText="Nr." SortExpression="CompanyId"
UniqueName="CompanyId" Visible="true" ReadOnly="true" MaxLength="5">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CompanyName" HeaderText="Unternehmensname" SortExpression="CompanyName"
UniqueName="CompanyName" Visible="true" ItemStyle-Width="150" DataFormatString="{0}" ReadOnly="true">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true">
<Selecting AllowRowSelect="true"></Selecting>
</ClientSettings>
</telerik:RadGrid>
and
<
telerik:RadGrid
ID
=
"rgProducts"
runat
=
"server"
AllowPaging
=
"True"
AllowAutomaticUpdates
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticDeletes
=
"True"
AllowSorting
=
"true"
DataSourceID
=
"Products"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"ProductId"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
UniqueName
=
"EditCommandColumn"
ShowSortIcon
=
"false"
>
<
HeaderStyle
ForeColor
=
"DimGray"
Width
=
"20px"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ConfirmText
=
"Dieses Produkt wirklich löschen?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Löschen"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
/>
<
telerik:GridBoundColumn
DataField
=
"ProductId"
HeaderText
=
"Nr."
SortExpression
=
"ProductId"
UniqueName
=
"ProductId"
Visible
=
"true"
ReadOnly
=
"true"
MaxLength
=
"5"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Grammage"
HeaderText
=
"Grammatur"
SortExpression
=
"Grammage"
UniqueName
=
"Grammage1"
Visible
=
"true"
ReadOnly
=
"false"
DataFormatString
=
"{0} g/m²"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Width"
HeaderText
=
"Breite"
SortExpression
=
"Width"
UniqueName
=
"Width"
Visible
=
"true"
ReadOnly
=
"false"
DataFormatString
=
"{0} cm"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Height"
HeaderText
=
"Höhe"
SortExpression
=
".Height"
UniqueName
=
"Height"
Visible
=
"true"
ReadOnly
=
"true"
DataFormatString
=
"{0} cm"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"NumberOfPages"
HeaderText
=
"Umfang"
SortExpression
=
"NumberOfPages"
UniqueName
=
"NumberOfPages"
Visible
=
"true"
ReadOnly
=
"true"
DataFormatString
=
"{0} Seiten"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PrintType1.PrintTypeName"
HeaderText
=
"Drucktyp"
SortExpression
=
"PrintType1.PrintTypeName"
UniqueName
=
"PrintType1.PrintTypeName"
Visible
=
"true"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Refinement1.RefinementName"
HeaderText
=
"Veredelung"
SortExpression
=
"Refinement1.RefinementName"
UniqueName
=
"Refinement1.RefinementName"
Visible
=
"true"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"PaperType1.PaperTypeName"
HeaderText
=
"Papersorte"
SortExpression
=
"PaperType1.PaperTypeName"
UniqueName
=
"PaperType1.PaperTypeName"
Visible
=
"true"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
asp:TextBox
ID
=
"tbGrammage"
runat
=
"server"
Text='<%# Bind("Grammage") %>'>
</
asp:TextBox
>
<
asp:TextBox
ID
=
"tbWidth"
runat
=
"server"
Text='<%# Bind("Width") %>'>
</
asp:TextBox
>
<
asp:TextBox
ID
=
"tbHeight"
runat
=
"server"
Text='<%# Bind("Height") %>'>
</
asp:TextBox
>
<
asp:TextBox
ID
=
"tbNumberOfPages"
runat
=
"server"
Text='<%# Bind("NumberOfPages") %>'>
</
asp:TextBox
>
<
asp:DropDownList
ID
=
"ddlPrintType"
runat
=
"server"
SelectedValue='<%# Bind("PrintType") %>' AppendDataBoundItems="true"
DataSourceID="PrintTypes" DataValueField="PrintTypeId" DataTextField="PrintTypeName">
</
asp:DropDownList
>
<
asp:DropDownList
ID
=
"ddlPaperType"
runat
=
"server"
SelectedValue='<%# Bind("PaperType") %>' AppendDataBoundItems="true"
DataSourceID="PaperTypes" DataValueField="PaperTypeId" DataTextField="PaperTypeName">
</
asp:DropDownList
>
<
asp:DropDownList
ID
=
"ddlRefinement"
runat
=
"server"
SelectedValue='<%# Bind("Refinement") %>' AppendDataBoundItems="true"
DataSourceID="Refinements" DataValueField="RefinementId" DataTextField="RefinementName">
</
asp:DropDownList
>
<
asp:Button
ID
=
"btnUpdate"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></
asp:Button
>
<
asp:Button
ID
=
"btnCancel"
Text
=
"Cancel"
runat
=
"server"
CausesValidation
=
"False"
CommandName
=
"Cancel"
></
asp:Button
>
</
FormTemplate
>
</
EditFormSettings
>
</
MasterTableView
>
<
ClientSettings
AllowKeyboardNavigation
=
"true"
EnablePostBackOnRowClick
=
"true"
>
<
Selecting
AllowRowSelect
=
"true"
></
Selecting
>
</
ClientSettings
>
</
telerik:RadGrid
>
and the DataSources:
<
asp:EntityDataSource
ID
=
"Companies"
runat
=
"server"
ConnectionString
=
"name=PortalEntities"
DefaultContainerName
=
"PortalEntities"
EnableFlattening
=
"False"
EntitySetName
=
"Companies"
EntityTypeFilter
=
"Company"
EnableInsert
=
"False"
EnableDelete
=
"False"
EnableUpdate
=
"False"
>
</
asp:EntityDataSource
>
<
asp:EntityDataSource
ID
=
"Refinements"
runat
=
"server"
ConnectionString
=
"name=PortalEntities"
DefaultContainerName
=
"PortalEntities"
EnableFlattening
=
"False"
EntitySetName
=
"Refinements"
EntityTypeFilter
=
"Refinement"
EnableInsert
=
"False"
EnableDelete
=
"False"
EnableUpdate
=
"False"
>
</
asp:EntityDataSource
>
<
asp:EntityDataSource
ID
=
"PaperTypes"
runat
=
"server"
ConnectionString
=
"name=PortalEntities"
DefaultContainerName
=
"PortalEntities"
EnableFlattening
=
"False"
EntitySetName
=
"PaperTypes"
EntityTypeFilter
=
"PaperType"
EnableInsert
=
"False"
EnableDelete
=
"False"
EnableUpdate
=
"False"
>
</
asp:EntityDataSource
>
<
asp:EntityDataSource
ID
=
"PrintTypes"
runat
=
"server"
ConnectionString
=
"name=PortalEntities"
DefaultContainerName
=
"PortalEntities"
EnableFlattening
=
"False"
EntitySetName
=
"PrintTypes"
EntityTypeFilter
=
"PrintType"
EnableInsert
=
"False"
EnableDelete
=
"False"
EnableUpdate
=
"False"
>
</
asp:EntityDataSource
>
<
asp:EntityDataSource
ID
=
"Products"
runat
=
"server"
ConnectionString
=
"name=PortalEntities"
DefaultContainerName
=
"PortalEntities"
EnableFlattening
=
"false"
EntitySetName
=
"Products"
EntityTypeFilter
=
"Product"
EnableInsert
=
"true"
EnableDelete
=
"true"
EnableUpdate
=
"true"
Where
=
"it.CompanyId = @CompanyId"
Include
=
"PrintType1, Refinement1, PaperType1"
>
<
WhereParameters
>
<
asp:ControlParameter
ControlID
=
"rgCompanies"
DefaultValue
=
"1"
Name
=
"CompanyId"
PropertyName
=
"SelectedValue"
Type
=
"int64"
/>
</
WhereParameters
>
</
asp:EntityDataSource
>
But now I have a problem. When I try to add a new product in the second grid, it doesn't get the correct value for the value "CompanyId" in "Products". But it is needed, as it is a foreign key.
I'm quite stuck with this and I'm sure, the solution is quite simple. But nothing I tried yet, worked in any way.
So I would appreciate, if someone can help me out with this.
Yours
Aljoscha