RadComboBox's (inside RadGrid) SelectedIndexChanged event NOT firing (only in Insert Mode)

34 posts, 0 answers
  1. Carlos Contreras
    Carlos Contreras avatar
    26 posts
    Member since:
    May 2010

    Posted 10 Dec 2010 Link to this post

    Hi Everybody!

    I have a RadComboBox inside a RadGrid's GridTemplateColumn, and I'm having problems when trying to use the RadComboBox's SelectedIndexChanged event.

    When the user is in Insert Mode, the event only fires after another control causes postback OR when he/she uses the Insert or Cancel commands. However, in Edit Mode there is NO problem at all.

    I have tried declaring the event in design mode (aspx) and made some tests, and then declaring it in Codebehind and made another tests. I even have tried declaring it both ways at the same time, but the result is the same.

    I'm wondering what could cause that behaviour, but I'm afraid I can't find any solution.

    I would share with you some info, because I think one of these points could be the cause of the issue:
    • RadComboBox is multicolumn (2 columns)
    • RadComboBox is being filled in it's ItemsRequested event
    • The RadGrid, which contains the RadComboBox, is inside a RadAjaxPanel
    • RadGrid's MasterTableView EditMode Property is "PopUp"
    • Besides the RadGrid, there are a RadToolTipManager and a RadInputManager controls in the WebForm
    • The WebForm, which contains the RadGrid, belongs to a ContentPlaceHolder
    • I'm using RadGrid version 2009.2.286.20

    I hope someboy can help me, or at least give me an idea to find a solution.

    Please, if you consider that it is necessary watching the code I'm using, let me know!


    Thanks for your attention!

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

    Posted 13 Dec 2010 Link to this post

    Hello Carlos,

    Here is a sample code which shows how to attach 'SelectedIndexCahnged' event to RadComboBox in insert and edit mode. Plase take a look at this code.

    ASPX:
    <telerik:GridTemplateColumn>
        <EditItemTemplate>
            <telerik:RadComboBox runat="server" ID="RadComboBox1">
            </telerik:RadComboBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>

    C#:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
      {
          if (e.Item is GridEditFormItem && e.Item.IsInEditMode)//if the item is in edit mode
          {
              GridEditFormItem editItem = (GridEditFormItem)e.Item;
              RadComboBox combo = (RadComboBox)editItem.FindControl("RadComboBox1");
              combo.AutoPostBack = true;
              combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);
          }
          if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)//if the item is in insert mode
          {
              GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
              RadComboBox combo = (RadComboBox)insertItem.FindControl("RadComboBox1");
              combo.AutoPostBack = true;
              combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);
          }
      }

    Please paste your code if it doesn't help.

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 29 Sep 2011 Link to this post

    Hi, i am velmurugan...
                                Currently working in chennai as software developer.
                                
                                now i am using  four tables
    like 1.branch(bname,bcode)
      2.semester(semcode,semname)
     3.section(sname,scode)
     4.studentdetail( id,rollno,studname,bname,semname,sname ) and this table have some data's.

    now i am creating new table like studentactivity(bname,semname,sname ,studname) all dats are displayed in radcombobox using radgrid.
    i need this code for that task
    once u r selecting bname,semname,sname when at a time related student names will displayed in dropdown

    Anyone plz help me.....urgently needed....

    Velmurugan-9894143542-chennai
  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 29 Sep 2011 Link to this post

    Hello Velmurugan,

    I am not sure if I fully understands your requirements, but I think these online demos would help you to achieve our goal:
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectedvalue/defaultcs.aspx
    http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx
    Please examine their markup and code and write us if you have some troubles.

    Greetings,
    Vasil
    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
  6. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 03 Oct 2011 Link to this post

    its same task,,,but i am using radgrid
               plz i will need like this task using radgrid cod ebehind c#.

             my task is ,now  u r select department ( EEE),section (A) from combobox ,at at time related student names are displayed in another combo box.plz urgently needed,i need a source for that task.

  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 06 Oct 2011 Link to this post

    Hi Velmurugan,

    If you want to create the grid pragmatically, check this resources that will help you:
    http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/groupby/defaultcs.aspx
    If you have some troubles with particular functionality, please write your requirements in night details and share us the code that you currently use. This way the forum members could help you for improving your code easier.

    All the best,
    Vasil
    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
  8. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 11 Oct 2011 Link to this post

    ok thanks sir....


                  but not like that......
  9. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 11 Oct 2011 Link to this post

    Hi Velmurugan,

    Check out this Code Library that might help to to achieve your scenario with related ComboBoxes inside RadGrid's edit form:
    http://www.telerik.com/community/code-library/aspnet-ajax/general/using-related-radcomboboxes-in-radgrid.aspx

    I hope this helps.

    Regards,
    Vasil
    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
  10. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 12 Oct 2011 Link to this post

    HI,,,,

          Ok fine thanks for response..
          I am using 4 combobox in radgrid and 4 different tables like ( branchmaster,semestermaster,sectionmaster) and studentdetails table contain (branchname,semestername,sectionname,studentname)

          1.selecting BRANCHNAME
    when display the particular semestername in second combo
          2.selecting SEMESTER 
    when disply the particular sectionname from semester in third combo
          3.selecting SECTIONNAME
          4.finally we will select particular student name from fourth combo

    plz help me..urgently need for my projects work,,
    i will submit within two days.........plz...
  11. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 17 Oct 2011 Link to this post

    Hello Velmurugan,

    Could you share a sample database that to use with the project? Because it is not clear what exactly is the relation in your table.
    Did you examined the CodeLibrary's source? Is this similar to what you need?

    Regards,
    Vasil
    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
  12. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 17 Oct 2011 Link to this post

    CREATE TABLE . [BRANCHMASTER] ( [BRANCHCODE] [nvarchar](50) NOT NULL, [BRANCHNAME] [nvarchar](50) NOT NULL, [DEPARTMENTCODE] [nvarchar](50) NULL, [COLLEGENAME] [nvarchar](50) NULL, [SEMESTERS] [nvarchar](50) NULL, [YEARS] [int] NULL, [PROGRAMMENAME] [nvarchar](50) NULL)

    CREATE TABLE [dbo].[SECTIONMASTER] ( [SECTIONCODE] [int] IDENTITY(1,1) NOT NULL, [SECTIONNAME] [varchar](20) NULL,
    [DEPARTMENT] [varchar](30) NULL, [COLLEGENAME] [varchar](70) NULL)

    CREATE TABLE [dbo].[SEMESTERMASTER ]( [SEMESTERCODE] [int] IDENTITY(1,1) NOT NULL,[SEMESTERNAME] [varchar](20) NULL, [DEPARTMENT] [varchar](30) NULL, [COLLEGENAME] [varchar](70) NULL, [ACTIVEFLAG] [varchar](20) NULL)

    CREATE TABLE [dbo].[STUDENTDETAILS]( [FROMYEAR] [nvarchar](4) NULL, [TOYEAR] [nvarchar](4) NULL, [BRANCHCODE] [nvarchar](50) NULL, [SEMESTERCODE] [nvarchar](50) NULL, [SECTIONCODE] [nvarchar](50) NULL, [BATCHCODE] [nvarchar](50) NULL, [REGISTERNO] [nvarchar](21) NULL, [ROLLNO] [nvarchar](21) NULL, [STUDENTNAME] [nvarchar](70) NULL, [ACTIVEFLAG] [nvarchar](1) NULL, [MASTERID] [nvarchar](60) NOT NULL, [DEPARTMENT] [nvarchar](50) NULL,[COLLEGECODE] [nvarchar](50) NULL, [ENTRYTYPE] [nvarchar](50) NULL)

    this is my sample sql query...plz help me...
  13. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 19 Oct 2011 Link to this post

    Hi Velmurugan,

    Now I see what is your database.
    In order to achieve the required functionality you could bind the three of the combo boxes using SQLDataSource directly to the BRANCHNAME, SEMESTER and SECTIONNAME tables.
    Then handle each of their SelectedIndexChanged events, and construct a SQL Query for the last ComboBox manually by concatenating the values from the first three combos in the where cause.

    Aspx:
    <telerik:RadComboBox runat="server" ID="RadComboBox1" DataSourceID="BRANCHNAME_DataSource"
      DataValueField="BRANCHCODE" DataTextField="BRANCHNAME" OnSelectedIndexChanged="RadComboBox123_SelectedIndexChanged">
    </telerik:RadComboBox>
    <telerik:RadComboBox runat="server" ID="RadComboBox2" DataSourceID="SEMESTER_DataSource"
      DataValueField="SECTIONCODE" DataTextField="SECTIONNAME" OnSelectedIndexChanged="RadComboBox123_SelectedIndexChanged">
    </telerik:RadComboBox>
    <telerik:RadComboBox runat="server" ID="RadComboBox3" DataSourceID="SECTIONNAME_DataSource"
      DataValueField="SEMESTERCODE" DataTextField="SEMESTERNAME" OnSelectedIndexChanged="RadComboBox123_SelectedIndexChanged">
    </telerik:RadComboBox>
    <telerik:RadComboBox runat="server" ID="RadComboBox4" OnSelectedIndexChanged="RadComboBox4_SelectedIndexChanged">
    </telerik:RadComboBox>
    <asp:SqlDataSource runat="server" ID="BRANCHMASTER_DataSource"></asp:SqlDataSource>
    <asp:SqlDataSource runat="server" ID="SECTIONMASTER_DataSource"></asp:SqlDataSource>
    <asp:SqlDataSource runat="server" ID="SEMESTERMASTER_DataSource"></asp:SqlDataSource>

    C#:
    protected void BindLastCombo()
    {
        SqlConnection con = new SqlConnection(".....your sql connection string.....");
     
        string sqlQuery = string.Format("SELECT [STUDENTNAME], [REGISTERNO] FROM [STUDENTDETAILS] WHERE BRANCHCODE = {0} AND SECTIONMASTER = {1} AND SEMESTERMASTER  = {2}", RadComboBox1.SelectedValue, RadComboBox2.SelectedValue, RadComboBox3.SelectedValue);
     
        SqlDataAdapter adapter = new SqlDataAdapter(sqlQuery, con);
        DataTable students = new DataTable();
     
        adapter.Fill(students);
     
        RadComboBox4.DataTextField = "STUDENTNAME";
        RadComboBox4.DataValueField = "REGISTERNO";
        RadComboBox4.DataSource = students;
        RadComboBox4.DataBind();
    }
     
    protected void RadComboBox123_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        BindLastCombo();
    }
    protected void RadComboBox4_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        //the student was selected
    }

    I believe this should work for you. Just make sure to set correctly the connection strings to all SQLDataSources.

    Also note that SECTIONCODE in SECTIONMASTER table is [int] and SECTIONCODE in STUDENTDETAILS in [nvarchar] you should fix this in order to mach if you use this field for relation between the tables.


    Best wishes,
    Vasil
    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
  14. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 20 Oct 2011 Link to this post

    hi..
         thanq so much...

    one think for me...this is my same task using session's.which is working well but my requirements is only will display the semestername,sectionname,branchname in radgrid - but its contain some code ,it should be stored in database..

      no error,but i got semester,section,branch code in radgrid,didn't get all names..only i will need all field names displaying in radgrid
     
     
    <script runat="server">

        protected void BRANCHCODEComboBox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Session["BRANCHCODE"] = ((RadComboBox)o).SelectedItem.Value;
            Session["SEMESTERCODE"] = ((RadComboBox)o).SelectedItem.Value;
            Session["SECTIONCODE"] = ((RadComboBox)o).SelectedItem.Value;
            Session["SelectedSTUDENTNAME"] = "";
            
            RadComboBox STUDENTNAMEComboBox = (RadComboBox)((RadComboBox)o).NamingContainer.FindControl("STUDENTNAMEComboBox");
            STUDENTNAMEComboBox.Items.Clear();
            STUDENTNAMEComboBox.DataBind();
        }
        protected void SEMESTERCODEComboBox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Session["SEMESTERCODE"] = ((RadComboBox)o).SelectedItem.Value;
            Session["SelectedSTUDENTNAME"] = "";


            RadComboBox STUDENTNAMEComboBox = (RadComboBox)((RadComboBox)o).NamingContainer.FindControl("STUDENTNAMEComboBox");
            STUDENTNAMEComboBox.Items.Clear();
            STUDENTNAMEComboBox.DataBind();
        }
        protected void SECTIONCODEComboBox_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Session["SECTIONCODE"] = ((RadComboBox)o).SelectedItem.Value;
            Session["SelectedSTUDENTNAME"] = "";
            RadComboBox STUDENTNAMEComboBox = (RadComboBox)((RadComboBox)o).NamingContainer.FindControl("STUDENTNAMEComboBox");
            STUDENTNAMEComboBox.Items.Clear();
            STUDENTNAMEComboBox.DataBind();
        }
        protected void student_OnSelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            Session["STUDENTNAME"] = ((RadComboBox)o).SelectedItem.Value;
            Session["SelectedSTUDENTNAME"] = ((RadComboBox)o).SelectedItem.Value;
        }
        
    </script>


    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>STUDENT ACTIVITY </title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            </telerik:RadScriptManager>
        </div>
       <div>
         <telerik:RadAjaxManager ID="ajaxradmanager" runat="server" >
              <AjaxSettings>
                  <telerik:AjaxSetting AjaxControlID="RadGrid1">
                  <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                            <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />
                        </UpdatedControls>
                  </telerik:AjaxSetting>
              </AjaxSettings>
            </telerik:RadAjaxManager>
          
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
             <telerik:RadGrid ID="RadGrid1" GridLines="Vertical" runat="server" AllowAutomaticDeletes="True"
                AllowAutomaticInserts="True" PageSize="10" AllowAutomaticUpdates="True" AllowPaging="True"
                AutoGenerateColumns="False" DataSourceID="SqlDataSource1"   BackColor="white" Skin="Office2007" >
                <MasterTableView EditMode="InPlace" DataKeyNames="BRANCHCODE" DataSourceID="SqlDataSource1" CommandItemDisplay="TopAndBottom" HorizontalAlign="NotSet">
                       <Columns>
                       
                         <telerik:GridEditCommandColumn ButtonType="ImageButton">
                              <ItemStyle CssClass="MyImageButton" />
                        </telerik:GridEditCommandColumn>
                         <telerik:GridButtonColumn 
                                       ConfirmText="Delete this country"
                                       ConfirmDialogType="RadWindow"
                                       ConfirmTitle="Delete" 
                                       ButtonType="ImageButton" 
                                       CommandName="Delete" 
                                       Text="Delete" 
                                       UniqueName="DeleteColumn">
                                <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                        </telerik:GridButtonColumn>
                            
                            <telerik:GridTemplateColumn HeaderText="BRANCHCODE" UniqueName="BRANCHCODE" >
                                <ItemTemplate>
                                    <%# Eval("BRANCHCODE") %>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox ID="BRANCHCODEComboBox" 
                                        AutoPostBack="true" DataSourceID="CountriesDataSource"
                                        DataTextField="BRANCHNAME" 
                                        DataValueField="BRANCHCODE" 
                                        Width="200PX" 
                                        SelectedValue='<%# Bind("BRANCHCODE") %>'
                                        runat="server" 
                                        OnSelectedIndexChanged="BRANCHCODEComboBox_SelectedIndexChanged">
                                    </telerik:RadComboBox>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                             <telerik:GridTemplateColumn HeaderText="SEMESTER NAME" UniqueName="SEMESTERCODE">
                                <ItemTemplate>
                                    <%# Eval("SEMESTERCODE")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox ID="SEMESTERCODEComboBox" 
                                         AutoPostBack="true" 
                                         DataSourceID="SqlDataSource2"
                                         DataTextField="SEMESTERNAME" 
                                         DataValueField="SEMESTERCODE" 
                                         SelectedValue='<%# Bind("SEMESTERCODE") %>'
                                         runat="server" 
                                         OnSelectedIndexChanged="SEMESTERCODEComboBox_SelectedIndexChanged">
                                    </telerik:RadComboBox>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            
                             <telerik:GridTemplateColumn HeaderText="SECTION NAME" UniqueName="SECTIONCODE">
                                <ItemTemplate>
                                    <%# Eval("SECTIONCODE")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <telerik:RadComboBox ID="SECTIONCODEComboBox" 
                                    AutoPostBack="true" DataSourceID="SqlDataSource3"
                                    DataTextField="SECTIONNAME" 
                                    DataValueField="SECTIONCODE" 
                                    SelectedValue='<%# Bind("SECTIONCODE") %>'
                                    runat="server" 
                                    OnSelectedIndexChanged="SECTIONCODEComboBox_SelectedIndexChanged">
                                    </telerik:RadComboBox>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            
                            <telerik:GridTemplateColumn HeaderText="STUDENTNAME" UniqueName="STUDENTNAME">
                                <ItemTemplate>
                                    <%# Eval("STUDENTNAME") %>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <%# Session["BRANCHCODE"] = Eval("BRANCHCODE")%>
                                      <%# Session["SEMESTERCODE"] = Eval("SEMESTERCODE")%>
                                        <%# Session["SECTIONCODE"] = Eval("SECTIONCODE")%>
                                          <%# Session["SelectedSTUDENTNAME"] = Eval("STUDENTNAME")%>
                                            <%# Session["SelectedSTUDENTNAME"] = Eval("SEMESTERCODE")%>
                                              <%# Session["SelectedSTUDENTNAME"] = Eval("SECTIONCODE")%>
                                              
                                    <asp:SqlDataSource ID="STUDENTNAMEDataSource" runat="server"  ConnectionString="<%$ ConnectionStrings:StudentConnectionString %>"
                                        SelectCommand="SELECT DISTINCT [STUDENTNAME] FROM [STUDENTDETAILS] Where BRANCHCODE=@BRANCHCODE AND SEMESTERCODE=@SEMESTERCODE AND SECTIONCODE=@SECTIONCODE "  >
                                       
                                         <SelectParameters>
                                             <asp:SessionParameter SessionField="BRANCHCODE" Type="String" Name="BRANCHCODE" />
                                               <asp:SessionParameter SessionField="SEMESTERCODE" Type="String" Name="SEMESTERCODE" />
                                                <asp:SessionParameter SessionField="SECTIONCODE" Type="String" Name="SECTIONCODE" />
                                          </SelectParameters>     
                                    </asp:SqlDataSource>
                                    
                                     <telerik:RadComboBox ID="STUDENTNAMEComboBox" DataSourceID="STUDENTNAMEDataSource" DataTextField="STUDENTNAME"
                                        DataValueField="STUDENTNAME"   SelectedValue='<%# Session["SelectedSTUDENTNAME"] %>' OnSelectedIndexChanged="student_OnSelectedIndexChanged" runat="server" Width="200PX">
                                     </telerik:RadComboBox>
                                </EditItemTemplate>
                            </telerik:GridTemplateColumn>
                            
                          <telerik:GridBoundColumn HeaderText="DISIPLINARY ACTION" UniqueName="DISIPLINARYACTION" DataField="DISIPLINARYACTION"  >
                              </telerik:GridBoundColumn>
                        
                        <telerik:GridBoundColumn HeaderText="AWARDS" UniqueName="AWARDS" DataField="AWARDS" >
                            </telerik:GridBoundColumn>
                        
                        <telerik:GridBoundColumn HeaderText="REMARKS" UniqueName="REMARKS" DataField="REMARKS" >
                            </telerik:GridBoundColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>


                <asp:SqlDataSource ID="SqlDataSource1" runat="server"  ConnectionString="<%$ ConnectionStrings:StudentConnectionString %>"
                  SelectCommand="SELECT [BRANCHCODE],[SEMESTERCODE],[SECTIONCODE],[STUDENTNAME],[DISIPLINARYACTION],[AWARDS],[REMARKS] FROM [STUDENT_DETAILS1]" InsertCommand="insert into STUDENT_DETAILS1 (BRANCHCODE,SEMESTERCODE,SECTIONCODE,STUDENTNAME,DISIPLINARYACTION,AWARDS,REMARKS) values(@BRANCHCODE,@SEMESTERCODE,@SECTIONCODE,@STUDENTNAME,@DISIPLINARYACTION,@AWARDS,@REMARKS)" 
                    DeleteCommand="delete from STUDENT_DETAILS1 where BRANCHCODE=@BRANCHCODE">
               
               <DeleteParameters>
                      <asp:Parameter Name="BRANCHCODE" Type="string"    />
                </DeleteParameters>
                <UpdateParameters>
                        <asp:Parameter Name="BRANCHCODE" Type="string"  />
                       <asp:Parameter Name="SEMESTERCODE" Type="string" />
                     <asp:Parameter Name="SECTIONCODE" Type="string" />
               <%-- <asp:Parameter Name="STUDENTNAME" Type="string"    />--%>
                    <asp:SessionParameter SessionField="SelectedSTUDENTNAME" Type="String" Name="STUDENTNAME" />
                      <asp:Parameter Name="DISIPLINARYACTION" Type="string" />
                        <asp:Parameter Name="AWARDS" Type="string" />
                          <asp:Parameter Name="REMARKS" Type="string" />
                </UpdateParameters>
                <InsertParameters>
                        <asp:Parameter Name="BRANCHCODE" Type="string"  />
                       <asp:Parameter Name="SEMESTERCODE" Type="string" />
                     <asp:Parameter Name="SECTIONCODE" Type="string" />
               <%-- <asp:Parameter Name="STUDENTNAME" Type="string"   />--%>
                 <asp:SessionParameter SessionField="SelectedSTUDENTNAME" Type="String" Name="STUDENTNAME" />
                     <asp:Parameter Name="DISIPLINARYACTION" Type="string" />
                       <asp:Parameter Name="AWARDS" Type="string" />
                         <asp:Parameter Name="REMARKS" Type="string" />
                </InsertParameters>
               
                </asp:SqlDataSource> 
                
                <asp:SqlDataSource ID="CountriesDataSource" runat="server"  ConnectionString="<%$ ConnectionStrings:StudentConnectionString %>"
                   SelectCommand="SELECT DISTINCT [BRANCHNAME],[BRANCHCODE] FROM [BRANCHMASTER]" >
                     </asp:SqlDataSource>
              
               <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:StudentConnectionString %>"
                SelectCommand="SELECT SEMESTERCODE,SEMESTERNAME FROM SEMESTERMASTER">
                      </asp:SqlDataSource>
                
              <asp:SqlDataSource ID="SqlDataSource3" runat="server"  ConnectionString="<%$ ConnectionStrings:StudentConnectionString %>"
                SelectCommand="SELECT [SECTIONNAME],[SECTIONCODE] FROM [SECTIONMASTER]">
                     </asp:SqlDataSource>
              
            </div>
        </form>
    </body>
    </html>

    plz help me ....





  15. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 20 Oct 2011 Link to this post

    hi..
         Mr.vasil thanq so much....but
          i have using your code but i got little of error (  The name 'RadComboBox1,2,3,4' does not exist in the current context ).
         plz i am a begginer  in telerik radcontrols...
         plz help me......
  16. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 24 Oct 2011 Link to this post

    Hi Velmurugan,

    When the ComboBoxes are in the grid, you will need to access them using FindControl for the given DataItem. Because they are created dinamically for each row, and can't be accessed directly from the Page. For example you could access the combo on ItemCreated event:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        RadComboBox comboBox = e.Item.FindControl("RadComboBox1") as RadComboBox;
        if (comboBox != null)
        {
            //You could manage the comboBox now
        }
    }
    Simillar if you have access to one of the combos you could use FindControl method of it's Parent to get the others.
    Aditionally you could check this help topic: http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

    All the best,
    Vasil
    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
  17. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 05 Nov 2011 Link to this post

    hi vasil,

            urgently need for my project,plz help me.......

            multiselect checkbox in radcombobox using radgrid.but we select multiple item from radcombo to stored in database like PERIOD 1,PERIOD 2,PERIOD 3..
           plz reply for how to insert and update the database.....that task will helpful for my future in my concerrn,this is last chance for me in my concern,otherwise they will reject from this concern,,,,anyone help me..

    i am using radlistbox only.. bt didn't work..my requirement is   multiselect checkbox in radcombobox using radgrid.but we selecting multiple item from radcombo to stored in database like PERIOD 1,PERIOD 2,PERIOD 3..

    <telerik:RadGrid id="RadGrid1" runat="server" Skin="Office2007" Width="100%" 
                   OnNeedDataSource="RadGrid1_NeedDataSource"
                    OnInsertCommand="RadGrid1_InsertCommand" ShowStatusBar="True" GridLines="Vertical"
                    AutoGenerateColumns="False" AllowPaging="true" PageSize="10" OnUpdateCommand="RadGrid1_UpdateCommand" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated"  >
                    <mastertableview commanditemdisplay="Top" width="100%" editmode="InPlace" DataKeyNames="PERIOD">
                    <NoRecordsTemplate>No records to show</NoRecordsTemplate>
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="EDIT">
                            <ItemStyle CssClass="MyImageButton" />
                  </telerik:GridEditCommandColumn>          
                  <telerik:GridButtonColumn ConfirmTitle="Delete" HeaderText="DELETE" ButtonType="ImageButton" ConfirmDialogType="RadWindow" CommandName="Delete" Text="Delete" ConfirmText="Are you sure that you want to delete this record?" UniqueName="DeleteColumn" >
                </telerik:GridButtonColumn>
                
                     <telerik:GridTemplateColumn HeaderText="PERIOD" UniqueName="PERIOD" DataField="PERIOD" >
                             <ItemTemplate>
                                  <%#Eval("PERIOD")%>
                             </ItemTemplate>
                            <EditItemTemplate>
                               <telerik:RadListBox ID="listbox" runat="server"  SelectionMode="Multiple" DataSourceID="sqlDataSource5" DataTextField="PERIOD" DataValueField="PERIOD">                       
                               </telerik:RadListBox>
                             </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="id"   HeaderText="id" UniqueName="id" >
                   </telerik:GridBoundColumn>  
                    <telerik:GridBoundColumn DataField="name"   HeaderText="name" UniqueName="name" >
                   </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="place"   HeaderText="place" UniqueName="place" >
                   </telerik:GridBoundColumn>               
                   <telerik:GridNumericColumn DataField="HALLTICKETHRS" DataFormatString="{0:N0}" UniqueName="HALLTICKETHRS" HeaderText="HALLTICKETHRS">
                       </telerik:GridNumericColumn>         
                  </Columns>
                 </mastertableview> 
                 <ValidationSettings CommandsToValidate="PerformInsert,Update" />
                </telerik:RadGrid>
    c# :
    int[] index = box.GetSelectedIndices();
                 int i;
                  string selectedvalue = "";
                foreach (object raditem in index)
                {
                    i = Convert.ToInt32(raditem);
                    selectedvalue = selectedvalue + box.Items[i].Value + ',';//getting Selected values
                }

     <asp:SqlDataSource ID="SqlDataSource5" runat="server"  ConnectionString="<%$ ConnectionStrings:StudentConnectionString %>"
                 SelectCommand="SELECT PERIOD FROM PERIODMASTER" >   
            </asp:SqlDataSource>
    thanks in advance,
    velmurugan,
  18. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 07 Nov 2011 Link to this post

    Hello Velmurugan,

    Instead of the RadList that you currently use, you could place a RadComboBox with EnableCheckAllItemsCheckBox="true".
    Then in the "RadGrid1_ItemDataBound" find your combo in the grid and add items to it depending on your database.
    Check this demo to see how to add items:
    http://demos.telerik.com/aspnet-ajax/combobox/examples/programming/addremovedisable/defaultcs.aspx
    Then you could access the checked items using CheckedItems property of the RadComboBox like in this demo:
    http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/checkboxes/defaultcs.aspx

    All the best,
    Vasil
    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
  19. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 22 Nov 2011 Link to this post

    hi....
             which link is possible for my task..
              http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/checkboxes/defaultcs.aspx
             but how to use in insert,update command using radgrid .

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

    Posted 23 Nov 2011 Link to this post

    Hello Velmurugan,

    Check the following demo which explains Insert/Update/Delete operations in RadGrid.
    Grid / Automatic Operations

    -Shinu.
  21. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 28 Nov 2011 Link to this post

    HI VASIL...
                       Sorry for asking...

                         what can i do in radcombo4_selectedindexchanged...tell me....
  22. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 28 Nov 2011 Link to this post

    hi vasil,
                 itz same task ...
                         http://www.telerik.com/community/code-library/aspnet-ajax/general/using-related-radcomboboxes-in- radgrid.aspx
                Have u used two tables in that task viewallusers,user..???

    my tables are,

    this is reference tables:
                         CREATE TABLE . [BRANCHMASTER] ( [BRANCHCODE] [nvarchar](50) NOT NULL, [BRANCHNAME] [nvarchar](50) NOT NULL,[DEPARTMENTCODE] [nvarchar](50) NULL, [COLLEGENAME] [nvarchar](50) NULL, [SEMESTERS] [nvarchar](50) NULL,[YEARS] [int] NULL, [PROGRAMMENAME] [nvarchar](50) NULL)

    CREATE TABLE [dbo].[SECTIONMASTER] ( [SECTIONCODE] [int] IDENTITY(1,1) NOT NULL, [SECTIONNAME] [varchar](20) NULL,
    [DEPARTMENT] [varchar](30) NULL,[COLLEGENAME] [varchar](70) NULL)

    CREATE TABLE [dbo].[SEMESTERMASTER ]([SEMESTERCODE] [int] IDENTITY(1,1) NOT NULL,[SEMESTERNAME] [varchar](20) NULL, [DEPARTMENT] [varchar](30) NULL,[COLLEGENAME] [varchar](70) NULL, [ACTIVEFLAG] [varchar](20) NULL)

    CREATE TABLE [dbo].[STUDENTDETAILS]( [FROMYEAR] [nvarchar](4) NULL, [TOYEAR] [nvarchar](4) NULL, [BRANCHCODE] [nvarchar](50) NULL,[SEMESTERCODE] [nvarchar](50) NULL,[SECTIONCODE] [nvarchar](50) NULL, [BATCHCODE] [nvarchar](50) NULL,[REGISTERNO] [nvarchar](21) NULL,[ROLLNO] [nvarchar](21) NULL, [STUDENTNAME] [nvarchar](70) NULL, [ACTIVEFLAG] [nvarchar](1) NULL, [MASTERID] [nvarchar](60) NOT NULL, [DEPARTMENT] [nvarchar](50) NULL,[COLLEGECODE] [nvarchar](50) NULL, [ENTRYTYPE] [nvarchar](50) NULL

    this is used for my task.
    SELECT [BRANCHCODE],[SEMESTERCODE],[SECTIONCODE],[STUDENTNAME],[DISIPLINARYACTION],[AWARDS],[REMARKS] FROM [STUDENT_DETAILS1]
          
    plz reply me.....
               
  23. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 28 Nov 2011 Link to this post

    Hi Velmurugan,

    The RadComboBox4_SelectedIndexChanged function will be executed when the 4th combo is selected.
    You see that the first three ComboBoxes we are just changing the datasource of the fourth as per your requirements. On the SelectedIndexChanged event of the combo you could do anything you need. For example you could store the values in the DataBase, show some notification to the user, perform some further steps. I am not aware what is your final goal in this project, so it is hardly to say what you can do on this event, it is something that you decide.

    Best wishes,
    Vasil
    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
  24. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 28 Nov 2011 Link to this post

    hi vasil,

            i got some error in that code like radcombobox1,2,3,4 doesn't exist in current context.

           i can't understand to your code,bcoz, can u give full source code for me

    plz reply me
  25. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 30 Nov 2011 Link to this post

    Hello Velmurugan,

    I will be glad to help you for your project if you have some difficulties using our controls or if you have some questions about them. Implementing the whole custom project by your requirements in the other hand is not something that we are able to do.

    Best wishes,
    Vasil
    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
  26. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 14 Dec 2011 Link to this post

    hi vasil....

     how to manage three combobox in item created event....
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        RadComboBox comboBox = e.Item.FindControl("RadComboBox1"as RadComboBox;
        if (comboBox != null)
        {
            here how to manage the comboBox..????
        }
    }


            
  27. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 16 Dec 2011 Link to this post

    Hello Velmurugan,

    You could see the server side API of the RadComboBox here:
    http://www.telerik.com/help/aspnet-ajax/allmembers_t_telerik_web_ui_radcombobox.html

    Kind regards,
    Vasil
    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
  28. Velmurugan
    Velmurugan avatar
    37 posts
    Member since:
    Aug 2011

    Posted 16 Dec 2011 Link to this post

    hi vasil...

              i can't understand tha link....
  29. Clive Hoggar
    Clive Hoggar avatar
    334 posts
    Member since:
    Nov 2008

    Posted 11 May 2013 Link to this post

    Hi Shinu

    I am trying to use this code idea for getting the combo box selected index changed event of an edit form, but converted to vb using the Telerik Converter, and this line causes a VS design time error where VS says I need to use RaiseEvent

    combo.SelectedIndexChanged += New RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged)

    Is there a problem with the c sharp code or the conversion? 


    Thanks

    Clive
  30. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 13 May 2013 Link to this post

    Hello Clive,

    In VB there is keyword called AddHandler that you can use:
    AddHandler combo.SelectedIndexChanged, AddressOf combo_SelectedIndexChanged

    The converter can not know if this is event or the += operator just adds value, so it can not convert it properly in this case. This is known for the compiler, because it knows the exact types of properties in your objects.

    Kind regards,
    Vasil
    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.
  31. moegal
    moegal avatar
    273 posts
    Member since:
    Jul 2007

    Posted 05 Mar 2014 Link to this post

    I could use some help??

    I am have an issue with related combo's in a radgrid GridTemplateColumn.

    Works fine the first time I change my selection in the combobox but it will not fire the OnSelectedIndexChanged event again.

    here is my markup:
    <telerik:GridTemplateColumn DataField="groupID" HeaderText="Group" UniqueName="groupID">
                                    <ItemTemplate>
                                        <asp:Label ID="lblGroup" runat="server" Text='<%# Eval("GroupName") %>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadComboBox ID="cmbGroup" runat="server"
                                            AutoPostBack="true"
                                            DataSourceID="SqlDataSourceGroups"
                                            DataTextField="GroupName"
                                            DataValueField="groupID"
                                            SelectedValue='<%# Eval("groupID") %>'
                                            OnSelectedIndexChanged="cmbGroup_SelectedIndexChanged">
                                        </telerik:RadComboBox>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
     
                                <telerik:GridTemplateColumn DataField="Sort" HeaderText="Sort" UniqueName="Sort"
                                    Display="false">
                                    <ItemTemplate>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadComboBox ID="cmbSort" runat="server">
                                        </telerik:RadComboBox>
                                        <asp:HiddenField ID="sortOriginal" runat="server" Value='<%#Bind("Sort") %>' />
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>

    in RadGrid1_ItemCreated I have:
    if (e.Item is GridEditFormItem && e.Item.IsInEditMode)//if the item is in edit mode
                {
                    GridEditFormItem editItem = (GridEditFormItem)e.Item;
                    RadComboBox combo = (RadComboBox)editItem.FindControl("cmbGroup");
                    combo.AutoPostBack = true;
                    combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cmbGroup_SelectedIndexChanged);
                }
                if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)//if the item is in insert mode
                {
                    GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
                    RadComboBox combo = (RadComboBox)insertItem.FindControl("cmbGroup");
                    combo.AutoPostBack = true;
                    combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cmbGroup_SelectedIndexChanged);
                }

    in RadGrid1_ItemDataBound:
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditableItem editedItem = e.Item as GridEditableItem;
     
                if (e.Item.OwnerTableView.IsItemInserted)
                {
                    RadComboBox cmbGroup = editedItem.FindControl("cmbGroup") as RadComboBox;
                    RadComboBox cmbSort = editedItem.FindControl("cmbSort") as RadComboBox;
     
                    cmbGroup.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cmbGroup_SelectedIndexChanged);
                    cmbGroup.AutoPostBack = true;
     
                    bool isnew = true;
                    cmbSort.DataSource = Products.GetCategorySortTableFromGroupID(isnew, Convert.ToInt32(cmbGroup.SelectedValue));
                    cmbSort.DataTextField = "SortDesc";
                    cmbSort.DataValueField = "Sort";
                    cmbSort.DataBind();
                }
                else
                {
                    DataRowView dataSourceRow = (DataRowView)e.Item.DataItem;
     
                    RadComboBox cmbGroup = editedItem.FindControl("cmbGroup") as RadComboBox;
                    RadComboBox cmbSort = editedItem.FindControl("cmbSort") as RadComboBox;
     
                    cmbGroup.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(cmbGroup_SelectedIndexChanged);
                    cmbGroup.AutoPostBack = true;
     
                    bool isnew = false;
                    cmbSort.DataSource = Products.GetCategorySortTableFromGroupID(isnew, Convert.ToInt32(cmbGroup.SelectedValue));
                    cmbSort.DataTextField = "SortDesc";
                    cmbSort.DataValueField = "Sort";
                    cmbSort.DataBind();
                    cmbSort.SelectedValue = dataSourceRow["groupID"].ToString();
     
                }
            }

    in cmbGroup_SelectedIndexChanged:
    GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;
     
            RadComboBox cmbGroup = sender as RadComboBox;
            
            RadComboBox cmbSort = editedItem["Sort"].FindControl("cmbSort") as RadComboBox;
     
            bool isnew = false;
            cmbSort.DataSource = Products.GetCategorySortTableFromGroupID(isnew, Convert.ToInt32(cmbGroup.SelectedValue));
            cmbSort.DataTextField = "SortDesc";
            cmbSort.DataValueField = "Sort";
            cmbSort.DataBind();

    thanks, Marty
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017