Trying to get the last detailgrid to work, everything loads fine up until I pick on the last grid (myModelGrid) to load and it does not find the parant key for the datagrid above. Even if i put in a hardcoded key it still loads nothing, even if something is there, at this point I am rather confused, made sure all keys are supposed to be what they are and are spelled and capped correctly. what it gives me is the following error
Incorrectt syntax near AND, which is part of the following, it does not get the parentkey. Can grid not go 4 levels down without doing something different, the funnly thing is I can add DB items to that level, but just not see them.
Incorrectt syntax near AND, which is part of the following, it does not get the parentkey. Can grid not go 4 levels down without doing something different, the funnly thing is I can add DB items to that level, but just not see them.
If e.DetailTableView.Name = "myModelGrid" Then
sql = "Select intModelId, intMakeId, strModel from Drat_Model where intMakeId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intMakeId") & " AND bitArchive IS NULL ORder by strModel"
e.DetailTableView.DataSource = getData(sql)
End If
<
telerik:RadGrid
ID
=
"myRadGrid"
runat
=
"server"
Width
=
"100%"
BorderWidth
=
"1px"
CellPadding
=
"4"
Skin
=
"Web20"
>
<
MasterTableView
AutoGenerateColumns
=
"false"
DataKeyNames
=
"intCategoryId"
HierarchyDefaultExpanded
=
"false"
Font-Size
=
"10"
Font-Names
=
"Veranda,arial,sans-serif"
HeaderStyle-HorizontalAlign
=
"Center"
Name
=
"MasterGrid"
ExpandCollapseColumn-ButtonType
=
"ImageButton"
HierarchyLoadMode
=
"Client"
AllowPaging
=
"True"
PageSize
=
"20"
PagerStyle-Mode
=
"NumericPages"
ExpandCollapseColumn-CollapseImageUrl
=
"~/Images/30.png"
ExpandCollapseColumn-ExpandImageUrl
=
"~/Images/29.png"
>
<
ItemStyle
HorizontalAlign
=
"Center"
/><
AlternatingItemStyle
BackColor
=
"#B0C4DE"
HorizontalAlign
=
"Center"
/><
HeaderStyle
ForeColor
=
"White"
Font-Bold
=
"true"
/>
<
DetailTables
>
<
telerik:GridTableView
Name
=
"myManufacGrid"
runat
=
"server"
DataKeyNames
=
"intManufacturerId"
TableLayout
=
"Fixed"
BorderWidth
=
"1px"
CellPadding
=
"6"
Font-Size
=
"10"
AutoGenerateColumns
=
"False"
HeaderStyle-HorizontalAlign
=
"Center"
BorderColor
=
"#404040"
Font-Names
=
"Veranda,arial,sans-serif"
GridLines
=
"Both"
ExpandCollapseColumn-ButtonType
=
"ImageButton"
ExpandCollapseColumn-CollapseImageUrl
=
"~/Images/30.png"
ExpandCollapseColumn-ExpandImageUrl
=
"~/Images/29.png"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"intCategoryId"
MasterKeyField
=
"intCategoryId"
/>
</
ParentTableRelation
>
<
HeaderStyle
Font-Bold
=
"true"
HorizontalAlign
=
"Center"
CssClass
=
"MostInnerHeaderStyle"
/>
<
ItemStyle
CssClass
=
"MostInnerItemStyle"
HorizontalAlign
=
"Center"
/>
<
AlternatingItemStyle
CssClass
=
"MostInnerAlernatingItemStyle"
HorizontalAlign
=
"Center"
/>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"intMakeID"
Name
=
"myMakeGrid"
Width
=
"100%"
TableLayout
=
"Fixed"
BorderWidth
=
"1px"
CellPadding
=
"6"
Font-Size
=
"10"
AutoGenerateColumns
=
"False"
HeaderStyle-HorizontalAlign
=
"Center"
BorderColor
=
"#404040"
Font-Names
=
"Veranda,arial,sans-serif"
GridLines
=
"Both"
ExpandCollapseColumn-ButtonType
=
"ImageButton"
ExpandCollapseColumn-CollapseImageUrl
=
"~/Images/30.png"
ExpandCollapseColumn-ExpandImageUrl
=
"~/Images/29.png"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"intManufacturerId"
MasterKeyField
=
"intManufacturerId"
/>
</
ParentTableRelation
>
<
HeaderStyle
Font-Bold
=
"true"
HorizontalAlign
=
"Center"
CssClass
=
"InnerSubHeaderStyle"
/><
ItemStyle
CssClass
=
"InnerSubItemStyle"
HorizontalAlign
=
"Center"
/>
<
AlternatingItemStyle
CssClass
=
"InnerSubAlernatingItemStyle"
HorizontalAlign
=
"Center"
/>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"intModelId"
Name
=
"myModelGrid"
Width
=
"100%"
TableLayout
=
"Fixed"
BorderWidth
=
"1px"
CellPadding
=
"6"
Font-Size
=
"10"
AutoGenerateColumns
=
"False"
HeaderStyle-HorizontalAlign
=
"Center"
BorderColor
=
"#404040"
Font-Names
=
"Veranda,arial,sans-serif"
GridLines
=
"Both"
ExpandCollapseColumn-ButtonType
=
"ImageButton"
ExpandCollapseColumn-CollapseImageUrl
=
"~/Images/30.png"
ExpandCollapseColumn-ExpandImageUrl
=
"~/Images/29.png"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"intMakeId"
MasterKeyField
=
"intMakeId"
/>
</
ParentTableRelation
>
<
HeaderStyle
Font-Bold
=
"true"
HorizontalAlign
=
"Center"
CssClass
=
"InnerSubHeaderStyle"
/><
ItemStyle
CssClass
=
"InnerSubItemStyle"
HorizontalAlign
=
"Center"
/>
<
AlternatingItemStyle
CssClass
=
"InnerSubAlernatingItemStyle"
HorizontalAlign
=
"Center"
/>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"MODEL"
DataField
=
"strModel"
/>
<
telerik:GridTemplateColumn
HeaderText
=
"Edit"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgModelEdit"
CommandArgument='<%# bind("intModelId") %>' CommandName="ModelEdit" ImageUrl="~/Images/edit_icon.png" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Archive"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgModelArchive"
CommandArgument='<%# bind("intModelId") %>' CommandName="ModelArchive" ImageUrl="~/Images/edit_icon.png"
OnClientClick="return confirm('Are you sure you want to archive this Model, This will Archive everything Underneath as well.');" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"MAKE"
DataField
=
"strmake"
/>
<
telerik:GridTemplateColumn
HeaderText
=
"ADD MODEL"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgAddPosition"
CommandArgument='<%# bind("intMakeID") %>' CommandName="AddModel" ImageUrl="~/Images/29.png" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Edit"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgMakeEdit"
CommandArgument='<%# bind("intMakeID") %>' CommandName="MakeEdit" ImageUrl="~/Images/edit_icon.png" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Archive"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgMakeArchive"
CommandArgument='<%# bind("intMakeID") %>' CommandName="MakeArchive" ImageUrl="~/Images/edit_icon.png"
OnClientClick="return confirm('Are you sure you want to archive this Make, This will Archive everything Underneath as well.');" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"MANUFACTURERS"
DataField
=
"strManufacturer"
></
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"ADD MAKE"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgAddPosition"
CommandArgument='<%# bind("intManufacturerId") %>' CommandName="AddMake" ImageUrl="~/Images/29.png" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Edit"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgManEdit"
CommandArgument='<%# bind("intManufacturerId") %>' CommandName="ManEdit" ImageUrl="~/Images/edit_icon.png" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Archive"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgManArchive"
CommandArgument='<%# bind("intManufacturerId") %>' CommandName="ManArchive" ImageUrl="~/Images/edit_icon.png"
OnClientClick="return confirm('Are you sure you want to archive this Manufacturer, This will Archive everything Underneath as well.');" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Category"
DataField
=
"strCategory"
/>
<
telerik:GridTemplateColumn
HeaderText
=
"Add Manufacturer"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgAdd"
CommandArgument='<%# bind("intCategoryId") %>' CommandName="AddMan" ImageUrl="~/Images/29.png" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Edit"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgCatEdit"
CommandArgument='<%# bind("intCategoryId") %>' CommandName="CatEdit" ImageUrl="~/Images/edit_icon.png" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Archive"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ID
=
"imgCatArchive"
CommandArgument='<%# bind("intCategoryId") %>' CommandName="CatArchive" ImageUrl="~/Images/edit_icon.png"
OnClientClick="return confirm('Are you sure you want to archive this Category, This will Archive everything Underneath as well.');" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Protected Sub myRadGrid_DetailTableDataBind(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles myRadGrid.DetailTableDataBind
If e.DetailTableView.Name = "myManufacGrid" Then
sql = "Select intManufacturerId, intCategoryId, strManufacturer from Drat_Manufacturer where intcategoryId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intCategoryId") & " AND bitArchive IS NULL " _
& "Order by strManufacturer"
e.DetailTableView.DataSource = getData(sql)
End If
If e.DetailTableView.Name = "myMakeGrid" Then
sql = "Select intMakeID, intManufacturerID, strMake from Drat_Make where intManufacturerID = " & e.DetailTableView.ParentItem.GetDataKeyValue("intManufacturerId") & " AND bitArchive IS NULL ORder by strMake"
e.DetailTableView.DataSource = getData(sql)
End If
If e.DetailTableView.Name = "myModelGrid" Then
sql = "Select intModelId, intMakeId, strModel from Drat_Model where intMakeId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intMakeId") & " AND bitArchive IS NULL ORder by strModel"
e.DetailTableView.DataSource = getData(sql)
End If
End Sub
Protected Sub myRadGrid_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myRadGrid.NeedDataSource
Dim Cat As Integer = ddlCategory.SelectedValue
Dim sqlWhere As String
If Cat > 0 Then
sqlWhere = "and intCategoryId = " & Cat & " Order by strCategory"
Else
sqlWhere = "Order by strCategory"
End If
sql = "Select intcategoryID, strCategory from Drat_Category where bitArchive IS NULL " & sqlWhere
myRadGrid.DataSource = getData(sql)
End Sub