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

RadComboBox Items in Array to linqDataSource

0 Answers 117 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sucheta Patil
Top achievements
Rank 1
Sucheta Patil asked on 24 Sep 2010, 04:45 PM
Hello,
I have a form on which I am selecting Student Name and populating Course Titles which is visible false on design
Courses could be 4 or 5 or more.
Now for each course I need to populate Tutor name and email.
I think I have to use Array for the courses but then how do I pass each array value to LinqDataSource to get TutorName.

My code snippet is:


student.aspx
******************************
  
<li>
        <asp:Label ID="lbStudName" runat="server" Text="Student Name: "  AssociatedControlID="lstStudName"
        </asp:Label>
        <telerik:RadComboBox ID="lstStudName"  runat="server" ShowToggleImage="false"
            DataTextField="SName" DataValueField="SName" ReadOnly="true" Enabled="true"
             AppendDataBoundItems="true" AutoPostBack="True"
            onselectedindexchanged="lstStudName_SelectedIndexChanged" >
            <Items><telerik:RadComboBoxItem Text="Choose One..." Value="0" /></Items>
              
            </telerik:RadComboBox>
         </li>
<li><asp:Label ID="lbCourseCode" runat="server" Text="Course Code: " Visible="true" AssociatedControlID="lstCourseCode"> </asp:Label>
              <telerik:RadComboBox ID="lstCourseCode"  runat="server" ShowToggleImage="true"
            DataTextField="CRef" DataValueField="CRef" Visible="true"
                  AppendDataBoundItems="True" ReadOnly="true" AutoPostBack="True">
                  </telerik:RadComboBox>
              
            </li>
<asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                    ContextTypeName="ModTTDataContext" 
                    TableName="StudentTutors">
                </asp:LinqDataSource>
  
  
*********************************
student.aspx.cs
**********************************
  
 protected void lstStudName_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string StudName = ((RadComboBox)o).SelectedItem.Text;
                BindCourse(StudName);
        string[] course;
        foreach( Items c  in course)
        {
           //linq query here
        }
        //   BindTutor(CREF);
          
       
    }
  
private void BindCourse(string StudName)
    {
        String[] str = StudName.Split(new char[] { ' ' });
        String fname = str[0];
        String lname = str[1];
        var query1 = (from z in modttdc.StudentInfos
                      where (z.Forenames.ToLower() == fname.ToLower()) && (z.Surname == lname.ToLower())
                      orderby z.Student_reference
                      select new
                      {
                          CRef = z.Course_Ref,
                          
                      }).Distinct();
        BindList(lstCourseCode, query1);
        //String CRef1 = lstCourseCode.SelectedItem.Text;
         
    }


Any help is appreciated.
Thanks
Sucheta

No answers yet. Maybe you can help?

Tags
ComboBox
Asked by
Sucheta Patil
Top achievements
Rank 1
Share this question
or