cannot list the students added by a specific studentId on selected index changed [Resolved]

Posted by Jopito under ASP.NET on 12/6/2013 | Points: 10 | Views : 1503 | Status : [Member] | Replies : 2
Hi pals,am filling a combobox with items from a method on event select index changed but i get the error input string was not in correct format and it cannot populate the tectbox,
here is my code

protected void StudentNameCombobox_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
ManageStudents manageStudents = new ManageStdents(WebUtility.GetConnectionString);

int StudentId =int.Parse(StudentNameCombobox.SelectedValue.ToString());
var query =manageStudents.GetStudentsByStudentId(studentId);
foreach (Students students in query)
{
Source3 nestudents = new Source3();
newStudents.student = (students.StydentId).ToString();
StudentIdCombobox.DataSource=manageStudents.GetStudentsByStudentId(StudentId);
studentIdCombobox.DataTextField = "StudentId";
studentIdCombobox.DataBind();
}

The combobox does not pick the students added by that particular studentId,,
Source3 is a class which contains newStudents by Get n set which is a string

Mark as answer if satisfied


Responses

Posted by: vishalneeraj-24503 on: 12/8/2013 [Member] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
I think,have you chacked StudentNameCombobox.SelectedValue has Id or not.
and do not use .Tostring(),always use convert.tostring(),because if your StudentNameCombobox.SelectedValue has null value or it has some text i.e. Select text,then .int.parst will throw an error,

Instead of int StudentId =int.Parse(StudentNameCombobox.SelectedValue.ToString());

Write:-

int StudentId = Convert.ToInt32(Convert.ToString(StudentNameCombobox.SelectedValue));

Please check this also.

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 12/6/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
check
https://demos.telerik.com/aspnet-ajax/combobox/examples/overview/defaultcs.aspx?_e_pi_=7%2CPAGE_ID10%2C7849023178
http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-handle-selectedindexchanged-of-a-radcombobox-in-a-nestedviewtemplate.aspx

http://stackoverflow.com/questions/9796255/how-to-use-jquery-or-javascript-to-get-the-selected-value-from-telerik-radcombob

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response