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

master detail grid with mysql - based on telerik samples wont work

3 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 2
Veteran
Jon asked on 03 Oct 2011, 08:57 PM
Took the following sample code:

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectedvalue/defaultvb.aspx

And adapted it to mysql and my dB, can get grids one and two working as they should but grid 3 will not show any data. what am i doing wrong?
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
 
 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ajaxsettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid3" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                    <telerik:AjaxUpdatedControl ControlID="RadGrid3" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid3">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid3" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </ajaxsettings>
    </telerik:RadAjaxManager>
     
    <strong>States:</strong>
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true"
        PageSize="5" DataSourceID="SqlDataSource1" GridLines="None" width="95%">
        <clientsettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">
            <Selecting AllowRowSelect="true" />
        </clientsettings>
        <mastertableview datakeynames="State" />
        <pagerstyle mode="NextPrevAndNumeric" />
    </telerik:RadGrid><br /><br />
     
    <strong>Companies:</strong>
    <telerik:RadGrid ID="RadGrid2" ShowStatusBar="true" runat="server"
        AllowPaging="True" PageSize="5" DataSourceID="SqlDataSource2" GridLines="None"
        width="95%" HorizontalAlign="NotSet">
        <mastertableview width="100%" datakeynames="State"
            datasourceid="SqlDataSource2">
        </mastertableview>
         <clientsettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">
            <Selecting AllowRowSelect="true" />
        </clientsettings>
        <pagerstyle mode="NextPrevAndNumeric" />
    </telerik:RadGrid><br /><br />
     
    <strong>Records:</strong>
    <telerik:RadGrid ID="RadGrid3" ShowStatusBar="true" runat="server"
        AllowPaging="True" PageSize="5" DataSourceID="SqlDataSource3" GridLines="None"
        width="95%" HorizontalAlign="NotSet">
        <mastertableview width="100%"
            datasourceid="SqlDataSource3">
        </mastertableview>
         <clientsettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">
            <Selecting AllowRowSelect="true" />
        </clientsettings>
        <pagerstyle mode="NextPrevAndNumeric" />
    </telerik:RadGrid>
 
 
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:connex %>"
        ProviderName="MySql.Data.MySqlClient" SelectCommand="
            SELECT EMPLOYER_STATE AS State,
            COUNT(EMPLOYER_STATE) as 'Total Filings'
            FROM y2010
            GROUP BY EMPLOYER_STATE
            ORDER BY COUNT(EMPLOYER_STATE) desc"
        runat="server"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:connex %>"
        ProviderName="MySql.Data.MySqlClient" SelectCommand="
        SELECT EMPLOYER_NAME AS Employer,
        EMPLOYER_STATE AS State,
        COUNT(EMPLOYER_NAME) as 'Total Filings'
        FROM y2010
        WHERE EMPLOYER_STATE=@state
        GROUP BY EMPLOYER_NAME
        ORDER BY COUNT(EMPLOYER_STATE) desc"
        runat="server">
        <SelectParameters>
         <asp:ControlParameter ControlID="RadGrid1" DefaultValue="CA" Name="State"
         PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:connex %>"
        ProviderName="<%$ ConnectionStrings:connex.ProviderName %>"
        SelectCommand="SELECT SOC_NAME, EMPLOYER_NAME AS Employer
        FROM y2010 WHERE (EMPLOYER_NAME = @Employer)"
        runat="server">
        <SelectParameters>
         <asp:ControlParameter ControlID="RadGrid2" name="Employer"
         PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>


3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 06 Oct 2011, 05:16 PM
Hello Jon,

 You can try setting DefaultValue for the SelectParameter in the third SqlDataSource control:

<asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:connex %>"
        ProviderName="<%$ ConnectionStrings:connex.ProviderName %>"
        SelectCommand="SELECT SOC_NAME, EMPLOYER_NAME AS Employer
        FROM y2010 WHERE (EMPLOYER_NAME = @Employer)"
        runat="server">
        <SelectParameters>
         <asp:ControlParameter ControlID="RadGrid2" name="Employer" DefaultValue = "default value"
         PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>

and also setting DataKeyNames for the third grid.Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Jon
Top achievements
Rank 2
Veteran
answered on 06 Oct 2011, 07:03 PM
what would i set as the data key name
and what would i put as the defualt value
0
Marin
Telerik team
answered on 07 Oct 2011, 08:08 AM
Hello Jon,

 You should set as DataKeyName a unique field in your table (e.g. SOC_NAME or EMPLOYER_NAME). As a default value you should set any existing value of the EMPLOYER_NAME field from the y2010 table. Similar to the way you did with the State select parameter in the SqlDataSource2 control.

Greetings,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Jon
Top achievements
Rank 2
Veteran
Answers by
Marin
Telerik team
Jon
Top achievements
Rank 2
Veteran
Share this question
or