This is a migrated thread and some comments may be shown as answers.

[Solved] Please help! why all of the detail rows bind to all of master rows?

6 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
louis chan
Top achievements
Rank 1
Iron
louis chan asked on 16 Mar 2010, 09:27 AM

Hi all,
I test this case in 2009 Q3 1314 and 2010 Q1 but the result is same. All of products are binding to each of category master row. But my others web page does not occur this logical bug!
please advice, thank you.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
</head> 
<body> 
    <form id="form1" runat="server">  
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1"   
                            LoadingPanelID="RadAjaxLoadingPanel1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">  
        </telerik:RadAjaxLoadingPanel> 
        <asp:AccessDataSource ID="AccessDataSource1" runat="server"   
            DataFile="~/App_Data/dbmx_with_category.mdb"   
            SelectCommand="SELECT * FROM [Categories] where isDelete = false"></asp:AccessDataSource> 
        <asp:AccessDataSource ID="AccessDataSource2" runat="server"   
            DataFile="~/App_Data/dbmx_with_category.mdb"   
            SelectCommand="SELECT * FROM [Products] where isDelete= False"></asp:AccessDataSource> 
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateDeleteColumn="True"   
            AutoGenerateEditColumn="True" DataSourceID="AccessDataSource1" GridLines="None">  
<MasterTableView AutoGenerateColumns="False" DataKeyNames="categoryID"   
                DataSourceID="AccessDataSource1" HierarchyLoadMode="ServerBind">  
    <DetailTables> 
        <telerik:GridTableView runat="server" DataKeyNames="productID"   
            DataSourceID="AccessDataSource2">  
            <ParentTableRelation> 
                <telerik:GridRelationFields DetailKeyField="categoryID"   
                    MasterKeyField="categoryID" /> 
            </ParentTableRelation> 
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn> 
        </telerik:GridTableView> 
    </DetailTables> 
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn Visible="True">  
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
        <telerik:GridBoundColumn DataField="categoryID" DataType="System.Int32"   
            HeaderText="categoryID" ReadOnly="True" SortExpression="categoryID"   
            UniqueName="categoryID">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="categoryTitle" HeaderText="categoryTitle"   
            SortExpression="categoryTitle" UniqueName="categoryTitle">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="categoryIcon" HeaderText="categoryIcon"   
            SortExpression="categoryIcon" UniqueName="categoryIcon">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="categorySequence" DataType="System.Int32"   
            HeaderText="categorySequence" SortExpression="categorySequence"   
            UniqueName="categorySequence">  
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="categoryParentID" DataType="System.Int32"   
            HeaderText="categoryParentID" SortExpression="categoryParentID"   
            UniqueName="categoryParentID">  
        </telerik:GridBoundColumn> 
        <telerik:GridCheckBoxColumn DataField="isDelete" DataType="System.Boolean"   
            HeaderText="isDelete" SortExpression="isDelete" UniqueName="isDelete">  
        </telerik:GridCheckBoxColumn> 
    </Columns> 
</MasterTableView> 
        </telerik:RadGrid> 
    </div> 
    </form> 
</body> 
</html> 
 

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Mar 2010, 11:36 AM
Hi,

You need to set the SelectCommand so that it accepts the CategoryID also as a parameter  for the AccessDataSource of your child grid:

ASPX:
<asp:AccessDataSource ID="AccessDataSource2" DataFile="~/Grid/Data/Access/Nwind.mdb" 
SelectCommand="SELECT * FROM [Products] where CategoryID= ? and IsDelete=false" runat="server"
           <SelectParameters> 
               <asp:Parameter Name="CategoryID" Type="Int32" /> 
           </SelectParameters> 
</asp:AccessDataSource> 

Princy
0
louis chan
Top achievements
Rank 1
Iron
answered on 16 Mar 2010, 09:17 PM
I forgot this one...thx for the remind!
BTW, I want to ask if I have a datasource which select parameter can be determined by query string or just select all as default query, then is that necessary to set "NeedDataSource Event" here? Thank you.
0
Princy
Top achievements
Rank 2
answered on 17 Mar 2010, 10:56 AM
Hi,

Here is a link on how to set the QueryStringParameter for your AccessDataSource .You could set the DefaultValue for select all:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.querystringparameter.aspx

Princy
0
louis chan
Top achievements
Rank 1
Iron
answered on 17 Mar 2010, 12:40 PM
Hi,
Yup, I know this one:
<asp:querystringparameter name="country" type="String" querystringfield="country" />

but does this parameter property also supported radgrid? It seems that the parameter is only for querystring



0
Princy
Top achievements
Rank 2
answered on 18 Mar 2010, 10:25 AM
Hi,

I was able to implement a similar scenario for my grid and I am able to filter the grid based on the querystring value passed.Please take a look at the aspx below:

ASPX:
  <telerik:RadGrid ID="RadGrid1" AutoGenerateEditColumn="False" runat="server" AutoGenerateColumns="true" 
        DataSourceID="SessionDataSource1" AllowSorting="True" Skin="Hay" AllowFilteringByColumn="True" 
        GridLines="None" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender"
        <PagerStyle Mode="NextPrevAndNumeric" /> 
        <HeaderContextMenu Skin="Hay"
            <CollapseAnimation Duration="200" Type="OutQuint" /> 
        </HeaderContextMenu> 
        <MasterTableView DataSourceID="AccessDataSource1"
            <Columns> 
                <telerik:GridBoundColumn UniqueName="ProductID" DataField="ProductID" HeaderText="ProductID"
                </telerik:GridBoundColumn> 
            </Columns> 
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn> 
        </MasterTableView> 
        <FilterMenu Skin="Hay"
            <CollapseAnimation Duration="200" Type="OutQuint" /> 
        </FilterMenu> 
    </telerik:RadGrid><br /> 
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb" 
        SelectCommand="SELECT ProductID, ProductName, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, Discontinued FROM [Products]" 
        DeleteCommand="DELETE FROM [Products] WHERE [ProductID] = ?" InsertCommand="INSERT INTO Products(ProductName, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, Discontinued) VALUES (?, ?, ?, ?, ?, ?)" 
        UpdateCommand="UPDATE [Products] SET [ProductName] = ?, [CategoryID] = ?, [QuantityPerUnit] = ?, [UnitPrice] = ?, [UnitsInStock] = ?, [Discontinued] = ? WHERE [ProductID] = ? AND [ProductName] = ? AND [CategoryID] = ? AND [QuantityPerUnit] = ? AND [UnitPrice] = ? AND [UnitsInStock] = ? AND [Discontinued] = ?" 
        FilterExpression="ProductID = '{0}'"
        <FilterParameters> 
            <asp:QueryStringParameter Name="ProductID" Type="String" DefaultValue="" QueryStringField="ID" /> 
        </FilterParameters> 
    </asp:AccessDataSource> 

Princy
0
louis chan
Top achievements
Rank 1
Iron
answered on 19 Mar 2010, 02:53 AM
hi Princy ,
Okay, I will try this by myself, thx a lot.

And...Why do your delete command and update command do not contain any parameter setting? Or this is just an example? Thx.
Tags
Grid
Asked by
louis chan
Top achievements
Rank 1
Iron
Answers by
Princy
Top achievements
Rank 2
louis chan
Top achievements
Rank 1
Iron
Share this question
or