Hi everyone,
Let me start by apologising for this question - despite being a competent VB6 programmer, I'm new to .NET and am aware that this question is the sort of one that would probably cause sniggers at the back of the class-room.
I'm trialling ASP.NET RadTools AJAX which I must say looks tremendous. I am slowly trying to get it to replicate the functionality I need before deciding on the direction to take to migrate some aging systems.
I don't normally post for help (I can normally work stuff out) but after spending two solid days piecing together various examples I can honestly say I'm stuck.
I am trying to create a RadGrid that allows me to drill down on related tables. I've seen various examples which include SQL markup within the actual page - but I'm trying to use an ObjectDataSource pointing to a SQL DataSet. This is to centralise the SQL markup making maintanence a tad easier.
My Main table is a table called LanSubnet with a PK of LanSubnetID and a FK of SiteID
The "drill down" table is called Site - with a PK of ID. The association between the two is "LanSubnet.SiteID=Site.ID"
So when someone drills down on a specific item, it shows all the associated sites - simple eh?
I'm trying to achieve this without coding - although if that is the only way, then so be it (I prefer VB.NET). My attempts either cause the details table to show all sites, or show none. I can't get it to only show the ones associated with the chosen master table and I've not got a clue why?
The SQL for LanSubnet is this:
SELECT LanSubnetID, SiteID, StartIP, EndIP, NTDomain, AdminUserName, AdminPassword, SNMPCommunityString, AuditStartDate, AuditFinishDate, AuditDevicesFound, AuditDevicesFailed, LastUpdatedUserID FROM dbo.LanSubnet
The SQL for the details (Site) table is this:
SELECT ID, CompanyID, PrimaryEmployeeID, Name, Description, [Address 1], [Address 2], County, [Post Code], [WWW Map Page], [Phone Number], [Fax Number], ScheduleNotes, Directions, [Local Station], IPaddress, OldData, Created, tmpSiteID, tmpCompanyID, longitude, latitude, Modified FROM dbo.Site WHERE ID=@SiteID
I'm attempting to pass to it @SiteID which will fix the issue! I'm assuming the GridRelationFields will filter the results? I've been trying to get it to work in the same way I got a drop-down to work?
As a side question - any suggestions what I should be reading to get my head around binding in general?
Many thanks in advance.
Here is my code:-
<%
@ Control Language="VB" AutoEventWireup="false" CodeFile="ProductsVB.ascx.vb" Inherits="TabStrip_Examples_ApplicationScenarios_LoadOnDemand_CustomersVB" %>
<%
@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
telerik:RadGrid runat="server" ID="RadGrid1" Skin="Office2007"
DataSourceID="ObjectDataSource1" AllowPaging="True" GridLines="None"
AutoGenerateEditColumn="True">
<
MasterTableView DataSourceID="ObjectDataSource1"
DataKeyNames="LanSubnetID">
<
RowIndicatorColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
RowIndicatorColumn>
<
ExpandCollapseColumn>
<
HeaderStyle Width="20px"></HeaderStyle>
</
ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="LanSubnetID" DataType="System.Int32"
HeaderText="LanSubnetID" ReadOnly="True" SortExpression="LanSubnetID"
UniqueName="LanSubnetID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SiteID" HeaderText="SiteID"
SortExpression="SiteID" UniqueName="SiteID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="StartIP" HeaderText="StartIP"
SortExpression="StartIP" UniqueName="StartIP">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="EndIP" HeaderText="EndIP"
SortExpression="EndIP" UniqueName="EndIP">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="NTDomain" HeaderText="NTDomain"
SortExpression="NTDomain" UniqueName="NTDomain">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AdminUserName" HeaderText="AdminUserName"
SortExpression="AdminUserName" UniqueName="AdminUserName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AdminPassword" HeaderText="AdminPassword"
SortExpression="AdminPassword" UniqueName="AdminPassword">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SNMPCommunityString"
HeaderText="SNMPCommunityString" SortExpression="SNMPCommunityString"
UniqueName="SNMPCommunityString">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AuditStartDate" DataType="System.DateTime"
HeaderText="AuditStartDate" SortExpression="AuditStartDate"
UniqueName="AuditStartDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AuditFinishDate" DataType="System.DateTime"
HeaderText="AuditFinishDate" SortExpression="AuditFinishDate"
UniqueName="AuditFinishDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AuditDevicesFound" DataType="System.Int32"
HeaderText="AuditDevicesFound" SortExpression="AuditDevicesFound"
UniqueName="AuditDevicesFound">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="AuditDevicesFailed" DataType="System.Int32"
HeaderText="AuditDevicesFailed" SortExpression="AuditDevicesFailed"
UniqueName="AuditDevicesFailed">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LastUpdatedUserID" DataType="System.Int32"
HeaderText="LastUpdatedUserID" SortExpression="LastUpdatedUserID"
UniqueName="LastUpdatedUserID">
</telerik:GridBoundColumn>
</Columns>
<
DetailTables>
<telerik:GridTableView runat="server" DataKeyNames="ID" AutoGenerateColumns="true" DataSourceID="ObjectDataSource2" HierarchyLoadMode="ServerOnDemand">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="ID" MasterKeyField="SiteID" />
</ParentTableRelation>
</telerik:GridTableView>
</DetailTables>
</
MasterTableView>
</
telerik:RadGrid>
<
asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="Delete" InsertMethod="Insert"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="DataSet1TableAdapters.LanSubnetTableAdapter" UpdateMethod="Update">
<DeleteParameters>
<asp:Parameter Name="Original_LanSubnetID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="SiteID" Type="Int32" />
<asp:Parameter Name="StartIP" Type="String" />
<asp:Parameter Name="EndIP" Type="String" />
<asp:Parameter Name="NTDomain" Type="String" />
<asp:Parameter Name="AdminUserName" Type="String" />
<asp:Parameter Name="AdminPassword" Type="String" />
<asp:Parameter Name="SNMPCommunityString" Type="String" />
<asp:Parameter Name="AuditStartDate" Type="DateTime" />
<asp:Parameter Name="AuditFinishDate" Type="DateTime" />
<asp:Parameter Name="AuditDevicesFound" Type="Int32" />
<asp:Parameter Name="AuditDevicesFailed" Type="Int32" />
<asp:Parameter Name="LastUpdatedUserID" Type="Int32" />
<asp:Parameter Name="Original_LanSubnetID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="SiteID" Type="Int32" />
<asp:Parameter Name="StartIP" Type="String" />
<asp:Parameter Name="EndIP" Type="String" />
<asp:Parameter Name="NTDomain" Type="String" />
<asp:Parameter Name="AdminUserName" Type="String" />
<asp:Parameter Name="AdminPassword" Type="String" />
<asp:Parameter Name="SNMPCommunityString" Type="String" />
<asp:Parameter Name="AuditStartDate" Type="DateTime" />
<asp:Parameter Name="AuditFinishDate" Type="DateTime" />
<asp:Parameter Name="AuditDevicesFound" Type="Int32" />
<asp:Parameter Name="AuditDevicesFailed" Type="Int32" />
<asp:Parameter Name="LastUpdatedUserID" Type="Int32" />
</InsertParameters>
</
asp:ObjectDataSource>
<
asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetOneSite"
TypeName="SiteTableAdapters.SiteTableAdapter">
<SelectParameters>
<asp:Parameter Name="SiteID" Type="Int32" />
</SelectParameters>
</
asp:ObjectDataSource>