Cascading comboboxes in RADGRID edit form

36 posts, 1 answers
  1. Balakrishna Reddy
    Balakrishna Reddy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 05 Oct 2012 Link to this post

    Hello telerik and other people,,please,,
          I have two  GridDropDwonColumns(Country,State) in my Rad Grid .. when i am trying to edit the ROW by clicking on the EDIT button my first(Country) DropDownList will display all the records based on the "countryID"  but i want to display the selected "country Name" as first element and following  other Country Names.
    for Ex:i have 
    CountryID     CountryName
    -------------------------------------
    1                      India
    2                      Pakistan
    3                      China
    4                      Japan
    ------------------------------------------
    and i am trying to edit the 2nd Row(2,Pakistan) my DropDownList will displaying as
    India
    Pakistan
    China  .......etc...
    ----------------------------------------
    But i want like.
    Pakistan     at first position and followed by other Country Names.
    ..........
    ........
    .........                                                                                                  
    So please help me how to Get this.

                       
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Oct 2012 Link to this post

    Hi,

    Please try the following code snippet I tried to give the selected item in the DropDownlist as the first item.

    ASPX:
    <telerik:GridDropDownColumn UniqueName="DropDownColumn" DropDownControlType="RadComboBox" DataSourceID="SqlDataSource1" ListTextField="OrderID" ListValueField="OrderID"></telerik:GridDropDownColumn>

    C#:
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem edit = (GridEditableItem)e.Item;
            RadComboBox combo = (RadComboBox)edit["DropDownColumn"].Controls[0];
            combo.SelectedItem.Text = (string)DataBinder.Eval(e.Item.DataItem, "OrderID").ToString();
        }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Balakrishna Reddy
    Balakrishna Reddy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 19 Oct 2012 Link to this post

    Hi,
      i have event handler i want to invoke that one.but not possible to me.
    Bellow is my Code......


    public delegate void PersonHandler(object sender,EventArgs e);
    public event PersonHandler CountrySelectedIndexChange;
    public event PersonHandler StateSelectedIndexChange;
    public event PersonHandler btnUploadClick;
    public event PersonHandler btnSubmitClick;


    protected virtual void rcbCountryName_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (this.CountrySelectedIndexChange != null)
            {
                this.CountrySelectedIndexChange(sender, e);
            }
        }
        protected void rcbStateName_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (this.StateSelectedIndexChange != null)
            {
                this.StateSelectedIndexChange(this,e);
            }
        }
    ********


    when i execute the above code i am getting null value from CountrySelectedIndexChange and it did not enter into if Loop......
    So please any one help me..


    Thanks
  5. Balakrishna Reddy
    Balakrishna Reddy avatar
    37 posts
    Member since:
    Oct 2012

    Posted 29 Oct 2012 Link to this post

    Hi,
       Please anybody Help me.
    I am using Rad Grid with web user control in Editformsettings mode as web control..I am using radasyuploader when i am clicking on upload button for updating  i am getting an error saying that :

    Insert item is available only when grid is in insert mode.

    The following is my MyUserControl.ascx file...

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="MyUserControl.ascx.cs" Inherits="MyUserControl" %>
    <%@ Register  Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>


    <style type="text/css">
        .style2
        {
            width: 270px;
        }
        .style3
        {
            width: 272px;
        }
    </style>


    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


    <table width="100%" >
    <tr>
    <td>
    <table id="Table3" cellspacing="1" cellpadding="1" width="100%" border="0">
        <tr>
            <td>
                <h3>Web User Control</h3>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Person ID &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            
                <telerik:RadTextBox ID="txtPID" runat="server" ReadOnly="true" Text='<%# DataBinder.Eval( Container, "DataItem.PID" ) %>' />
                <br />
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3">
                Person Name &nbsp; &nbsp;&nbsp;
                <telerik:RadTextBox ID="txtPName" runat="server" Text='<%# DataBinder.Eval( Container, "DataItem.PName" ) %>' />
                <br />
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3">
                Country Name &nbsp;&nbsp;
                <telerik:RadComboBox ID="rcbCountryName" runat="server" AutoPostBack="true"
                    DataMember='<%# DataBinder.Eval( Container, "DataItem.COU_Name" ) %>' DataValueField="COU_Name"
                     DataTextField="COU_Name" Text='<%# DataBinder.Eval( Container, "DataItem.COU_Name" ) %>'
                    onselectedindexchanged="rcbCountryName_SelectedIndexChanged" />
                &nbsp;&nbsp;
                <br />
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3">
                State Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <telerik:RadComboBox ID="rcbStateName" runat="server"  AutoPostBack="true"
                    DataMember='<%# DataBinder.Eval( Container, "DataItem.STE_Name" ) %>' 
                    DataValueField="STE_Name" Text='<%# DataBinder.Eval( Container, "DataItem.STE_Name" ) %>'
                    onselectedindexchanged="rcbStateName_SelectedIndexChanged" />
                &nbsp;&nbsp;
                <br />
                <br />
            </td>
        </tr>
        <tr>
            <td class="style3">
                City Name &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <telerik:RadComboBox ID="rcbCityName" runat="server"  AutoPostBack="true"
                    DataMember='<%# DataBinder.Eval( Container, "DataItem.CIT_Name" ) %>' 
                    DataValueField="CIT_Name" 
                    Text='<%# DataBinder.Eval( Container, "DataItem.CIT_Name" ) %>' />
                &nbsp;&nbsp;
                <br />
                <br />
            </td>
       </tr>
     </table>
     </td>
     <td>
    <table id="Tabl2" cellspacing="1" cellpadding="1" width="100%" border="0">
        <tr>
            <td>
                <telerik:RadAsyncUpload ID="Uplader" runat="server" TargetFolder="Photos"
                        Height="25px" onfileuploaded="Uplader_FileUploaded" Skin="Sunset" 
                    Width="243px"/>
                <br />
                <br />
                &nbsp;&nbsp;&nbsp;&nbsp;
                <asp:Button ID="btnUpload" runat="server"  Text="UploadFile"
                        CommandName="PerformInsert" Visible="true" Width="96px" onclick="btnUpload_Click"/>
                <br />
            </td> &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
            <td>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <telerik:RadBinaryImage ID="radbinaryimg" runat="server" Height="80px" ImageUrl='<%#"~/Photos/" + Eval("IMG_Name") %>' />
            </td>
        </tr>
       <tr>
        <td class="style2">
            &nbsp;&nbsp;&nbsp;&nbsp;
            Width="89px"/>
            &nbsp;&nbsp;&nbsp;--%>
            <asp:Button ID="btnSubmit" runat="server" CommandName="PerformInsert" 
                Visible="true" Width="96px" onclick="btnSubmit_Click"></asp:Button>
                    &nbsp;&nbsp;&nbsp;  
            <asp:Button ID="btnCancel" Text="Cancel" runat="server"  CausesValidation="False" CommandName="Cancel" Width="96px" 
                onclick="btnCancel_Click"></asp:Button>
                         </asp:Button>
                <asp:Button ID="btnInsert" Text="Insert" runat="server" CommandName="PerformInsert"
                    Visible='<%# "DataItem" is Telerik.Web.UI.GridInsertionObject %>'></asp:Button>
                &nbsp;
    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
    CommandName="Cancel"></asp:Button>--%>
        </td>
       </tr>
    </table>
    </td>
    </tr>
    </table>

    *************************************
    and MyUserControlPage.aspx is as follows:
    *************************************************

    <body>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>


        <div>
            <telerik:RadGrid ID="RadGrid1" runat="server" 
                 AutoGenerateColumns="False" AllowPaging="True" PageSize="5" Skin="Vista" 
                onitemcommand="RadGrid1_ItemCommand" onitemdatabound="RadGrid1_ItemDataBound" onupdatecommand="RadGrid1_UpdateCommand" 
                >
                <PagerStyle Mode="NextPrevAndNumeric" />
                <MasterTableView DataKeyNames="PID" CommandItemDisplay="TopAndBottom">
                  <Columns>
                        <telerik:GridEditCommandColumn UniqueName="Editcolumn"></telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn  DataField="PID" ReadOnly ="true" UniqueName="Pid" Visible="false" >
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="PName" HeaderText="Person Name" UniqueName="PName">
                        </telerik:GridBoundColumn>
                        <telerik:GridDropDownColumn DataField="COU_Name" UniqueName="COU_Name" HeaderText="Country Name" ListDataMember="Country_Master" ListValueField="COU_Name" >
                        </telerik:GridDropDownColumn>
                        <telerik:GridDropDownColumn DataField="STE_Name" UniqueName="STE_Name" HeaderText="State Name" ListDataMember="State_Master" ListValueField="STE_Name" >
                        </telerik:GridDropDownColumn>
                        <telerik:GridDropDownColumn DataField="CIT_Name" UniqueName="CIT_Name" HeaderText="City Name" ListDataMember="City_Master" ListValueField="CIT_Name" >
                        </telerik:GridDropDownColumn>
                        <telerik:GridTemplateColumn HeaderText="Image" UniqueName="IMAGE">
                            <ItemTemplate>
                                <telerik:RadBinaryImage ID="radbinaryimg" runat="server" Height="80px" ImageUrl='<%# "~/Photos/" + Eval("IMG_Name") %>' />
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                  </Columns>
                    <EditFormSettings UserControlName="~/MyUserControl.ascx" EditFormType="WebUserControl">
                        <EditColumn UniqueName="EditColumn1" ButtonType="ImageButton"></EditColumn>
                    </EditFormSettings>
                </MasterTableView>
            </telerik:RadGrid>
        </div>
        </form>
    </body>
    </html>
    ***********************************************************
    My problem is that i want insert and update values.So Please help me.
    please help me what i want to write in MyUserControl.ascx.csfile and in ASPX.CS file.
    Please.
    please.
    please.

  6. Nidhi
    Nidhi avatar
    1 posts
    Member since:
    Mar 2013

    Posted 04 Oct 2013 Link to this post

    using Telerik cascading dropdownlist, when i want to edit record by click on telerik grid the data is showing in first dropdownlist which is country and second state dropdownlist is not showing its value ,when oncahnge event occur in state dropdown then state dropdown get selected correct pls help me....
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Oct 2013 Link to this post

    Hi Nidhi ,

    Please have a look at the following demo which shows the Cascading Combobox in edit mode.
    Grid - Accessing Cells and Rows

    Thanks,
    Shinu
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017