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

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

33 Answers 1151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Carlos Contreras
Top achievements
Rank 1
Carlos Contreras asked on 10 Dec 2010, 08:45 PM
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!

33 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Dec 2010, 11:49 AM
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.
0
Velmurugan
Top achievements
Rank 1
answered on 29 Sep 2011, 10:05 AM
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
0
Vasil
Telerik team
answered on 29 Sep 2011, 11:54 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 03 Oct 2011, 12:42 PM
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.

0
Vasil
Telerik team
answered on 06 Oct 2011, 11:50 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 11 Oct 2011, 11:37 AM
ok thanks sir....


              but not like that......
0
Vasil
Telerik team
answered on 11 Oct 2011, 11:57 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 12 Oct 2011, 10:15 AM
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...
0
Vasil
Telerik team
answered on 17 Oct 2011, 09:52 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 17 Oct 2011, 12:33 PM
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...
0
Vasil
Telerik team
answered on 19 Oct 2011, 03:29 PM
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
0
Velmurugan
Top achievements
Rank 1
answered on 20 Oct 2011, 07:07 AM
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 ....





0
Velmurugan
Top achievements
Rank 1
answered on 20 Oct 2011, 07:18 AM
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......
0
Vasil
Telerik team
answered on 24 Oct 2011, 08:28 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 05 Nov 2011, 08:09 AM
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,
0
Vasil
Telerik team
answered on 07 Nov 2011, 11:04 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 22 Nov 2011, 12:47 PM
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 .

0
Shinu
Top achievements
Rank 2
answered on 23 Nov 2011, 06:06 AM
Hello Velmurugan,

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

-Shinu.
0
Velmurugan
Top achievements
Rank 1
answered on 28 Nov 2011, 07:21 AM
HI VASIL...
                   Sorry for asking...

                     what can i do in radcombo4_selectedindexchanged...tell me....
0
Velmurugan
Top achievements
Rank 1
answered on 28 Nov 2011, 08:05 AM
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.....
           
0
Vasil
Telerik team
answered on 28 Nov 2011, 09:13 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 28 Nov 2011, 10:03 AM
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
0
Vasil
Telerik team
answered on 30 Nov 2011, 10:20 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 14 Dec 2011, 06:04 AM
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..????
    }
}


        
0
Vasil
Telerik team
answered on 16 Dec 2011, 11:05 AM
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
0
Velmurugan
Top achievements
Rank 1
answered on 16 Dec 2011, 11:09 AM
hi vasil...

          i can't understand tha link....
0
Clive Hoggar
Top achievements
Rank 1
answered on 11 May 2013, 05:13 PM
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
0
Vasil
Telerik team
answered on 13 May 2013, 12:12 PM
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.
0
moegal
Top achievements
Rank 1
answered on 05 Mar 2014, 04:24 PM
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
0
moegal
Top achievements
Rank 1
answered on 05 Mar 2014, 05:46 PM
seems this will not work if I am validating an item client side?  That can't be right?

What is the work around for this? I should be able to post back an item more that once right?
0
Shinu
Top achievements
Rank 2
answered on 06 Mar 2014, 05:10 AM
Hi Moegal,

Your code is working fine at my end. Please declare the OnSelectedIndexChanged event only in the ASPX page. Remove the ItemCreated event codes.

ASPX:​
<EditItemTemplate>
    <telerik:RadComboBox ID="cmbGroup" runat="server"
        AutoPostBack="true"
        DataSourceID="SqlDataSourceGroups"
        DataTextField="GroupName"
        DataValueField="groupID"
        SelectedValue='<%# Eval("groupID") %>'
        OnSelectedIndexChanged="cmbGroup_SelectedIndexChanged">
    </telerik:RadComboBox>
</EditItemTemplate>

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridEditableItem && e.Item.IsInEditMode)
  {
   GridEditableItem editedItem = e.Item as GridEditableItem;
   if (e.Item.OwnerTableView.IsItemInserted)
   {
    //Your codes    
   }
  }
  protected void cmbGroup_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
  {
 
   GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem;
   RadComboBox cmbGroup = sender as RadComboBox;
    //   Your codes
  }

Thanks,
Shinu
0
Jaspal
Top achievements
Rank 1
answered on 28 May 2015, 11:53 AM
  RadComboBox combo = sender as RadComboBox;
            GridDataItem item = (GridDataItem)combo.NamingContainer;
            int index = item.ItemIndex;
0
Jaspal
Top achievements
Rank 1
answered on 28 May 2015, 11:55 AM
                    <telerik:RadComboBox ID="ddlMonth" runat="server" Width="120px" AutoPostBack="True"  SelectedValue='<%# Eval("groupID") %>' OnSelectedIndexChanged="ddlMonth_SelectedIndexChanged">
                        <Items>
                            <telerik:RadComboBoxItem Value="1" Text="January" />
                            <telerik:RadComboBoxItem Value="2" Text="February" />
                            <telerik:RadComboBoxItem Value="3" Text="March" />
                            <telerik:RadComboBoxItem Value="4" Text="April" />
                            <telerik:RadComboBoxItem Value="5" Text="May" />
                            <telerik:RadComboBoxItem Value="6" Text="June" />
                        </Items>
                    </telerik:RadComboBox>
Tags
Grid
Asked by
Carlos Contreras
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Velmurugan
Top achievements
Rank 1
Vasil
Telerik team
Clive Hoggar
Top achievements
Rank 1
moegal
Top achievements
Rank 1
Jaspal
Top achievements
Rank 1
Share this question
or