Treeview with parameter from RadGrid

7 posts, 0 answers
  1. Heinz
    Heinz avatar
    20 posts
    Member since:
    Mar 2008

    Posted 01 Apr 2009 Link to this post

    I have a RadGrid for a news management system. In EditFormSettings – FormTemplate I need a Treeview inside the FormTemplate which depends on the ArticleID of the news in edit mode. Data for Treeview comes from a stored procedure which expects ArticleID as parameter.

    I expected that
    <telerik:RadTreeView ID="RadTreeView1" runat="server" DataFieldID="PortalID"  
                                    DataNavigateUrlField="PortalID" DataSourceID="SqlPortalTreeDataSource"   
                                    DataTextField="PortalName" DataValueField="PortalID"
                                </telerik:RadTreeView> 
     
    <asp:SqlDataSource ID="SqlPortalTreeDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>"  
    SelectCommand="peRedPlan_GetPortalsTree" SelectCommandType="StoredProcedure"
    <SelectParameters> 
        <asp:ControlParameter  ControlID="RadGrid1" Name="ArticleID"  PropertyName="SelectedValue" Type="Int32" /> 
    </SelectParameters> 
    </asp:SqlDataSource> 
     
    brings up the TreeView. SQL Server Profiler shows me, that the StoredProcedure is not started. If I set a default value in SelectParameters (e.g. 7272) all runs fine and TreeView is created. So I suppose, that RadGrid1 does not provide ArticleID for SelectParameters. Or what runs wrong?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Apr 2009 Link to this post

    Hi Heinz,,

    Would you please try the below ControlParameter   declaration and let me know whether it works.

     
     
     
     <asp:ControlParameter ControlID="RadGrid1" Name="ArticleID" DefaultValue="7272" 
                       PropertyName="SelectedValues['ArticleID']" Type="Int32" /> 


    -Shinu.
  3. Heinz
    Heinz avatar
    20 posts
    Member since:
    Mar 2008

    Posted 02 Apr 2009 Link to this post

    No, does not work. Profiler shows me, that the sp is still called with the default value  and with not the current ArticleID.
  4. Heinz
    Heinz avatar
    20 posts
    Member since:
    Mar 2008

    Posted 02 Apr 2009 Link to this post

    Hi,
    seems not to be a issue from Treeview but from RadGrid. I tried RadCombobox or simple ASP dropdownlist instead of Treeview. All the same, RadGrid does not provide the ArticleID as ControlParameter. But it shows me ArticleID in Editmode as Literal. e.g. as
    <%#Eval("ArticleID")%> 
    Any idea?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Apr 2009 Link to this post

    Hi Heinz,

    I have used the radgrid in one of my application just like the related grid where I'm passing the Id from first grid to populate the second, so i think that it is not the problem with the Radgrid.
    Would you please check whether your radgrid is placed inside any control so that while rendering to html it's clientId will be different from RadGrid1

    for example if the grid is inside rock itz clientid will be like this  "RadDock1$C$RadGrid1"
    so you have to use the  ControlParameter  statement as shown below.

     <asp:ControlParameter 
    ControlID="RadDock1$C$RadGrid1"
     Name="ArticleID"
     DefaultValue="7272" 
     PropertyName="SelectedValues['ArticleID']" 
    Type
    ="Int32" /> 

    Here is the online demo of related grid showing how to pass the selected Id from the Radgrid as controlPaermeter.

    -Shinu
  6. Heinz
    Heinz avatar
    20 posts
    Member since:
    Mar 2008

    Posted 03 Apr 2009 Link to this post

    Thanks Shinu,
    but I got some code behind via support ticket yesterday  which runs fine. I will check your solution next days.
    Thanks to you and the Telerik team.
    Heinz
    public partial class _Default : System.Web.UI.Page  
        int categoryID; 
        protected void Page_Load(object sender, EventArgs e) 
        { 
     
        } 
        protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e) 
        { 
            e.Command.Parameters[0].Value = categoryID
        } 
        protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            { 
                categoryID = Convert.ToInt32(((GridEditableItem)e.Item).GetDataKeyValue("CategoryID")); 
            } 
        } 
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
     
        } 

  7. Robert
    Robert avatar
    49 posts
    Member since:
    Sep 2008

    Posted 25 Nov 2009 Link to this post

    I have this same problem everytime I use Custom edit templates. Here is my SQL statement which feeds my treeview however I cannot get the parameter value from radgrid1.

    SQL for RADGRID1......  
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"   
            ConnectionString="<%$ ConnectionStrings:TESTDEVConnection %>"   
            SelectCommand="SELECT Dictationid, Dictatorid, Jobstate, AssignedTranID, PriorityLevel, Worktype, Datedictated, DateUploaded, [Document] FROM Dictations">  
        </asp:SqlDataSource> 
     
     
    SQL for Treeview.....  
    <asp:SqlDataSource ID="SqlDataSource5" runat="server"   
            ConnectionString="<%$ ConnectionStrings:TESTDEVConnection %>"   
              
            SelectCommand="SELECT BillingID, Dictationid, Code, Parentid, Text FROM Dictation_Billingcodes WHERE (Dictationid = @Dictationid)">  
            <SelectParameters> 
                <asp:ControlParameter ControlID="RadGrid1" Name="Dictationid"   
                    PropertyName="SelectedValue" DefaultValue="1" /> 
            </SelectParameters> 
    have have tried both suggestions in this post with no success. Does anyone have a way to get this parameter value?
Back to Top