G
Guest
I have bind a dataset, DentistDataSet1, to TextBox, txtLastName, by set the
textbox property (databindings--> simple binding--> ... -->LastName) and also
bind it to a dropdown list, DropdownList1 with datasource (DentistDataSet1),
DataMember (Dentists), and DataTextField (DentistID), and AutoPostBack(true).
The settings are done by Visual .NET studio 2003.
Also I have the following event code and expect the FirstName and LastName
would be changed with selecting another DentistID in the dropdown list.
-------
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
txtLastName.Text =
DentistDataSet1.Tables(0).Rows(DropDownList1.SelectedIndex)("LastName")
txtFirstName.Text =
DentistDataSet1.Tables(0).Rows(DropDownList1.SelectedIndex)("FirstName")
End Sub
------
When I select a new DentistID, I got the following error:
------
Exception Details: System.IndexOutOfRangeException: There is no row at
position 1.
Source Error:
Line 182: 'txtLastName.DataBind()
Line 183: 'txtFirstName.DataBind()
Line 184: txtLastName.Text =
DentistDataSet1.Tables(0).Rows(DropDownList1.SelectedIndex)("LastName")
Line 185: txtFirstName.Text =
DentistDataSet1.Tables(0).Rows(DropDownList1.SelectedIndex)("FirstName")
Line 186:
------
Any one could help me to figure out the problem? Or what is the correct
steps to set up the properties and coding to get my expected result?
Thank you very much
David
textbox property (databindings--> simple binding--> ... -->LastName) and also
bind it to a dropdown list, DropdownList1 with datasource (DentistDataSet1),
DataMember (Dentists), and DataTextField (DentistID), and AutoPostBack(true).
The settings are done by Visual .NET studio 2003.
Also I have the following event code and expect the FirstName and LastName
would be changed with selecting another DentistID in the dropdown list.
-------
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged
txtLastName.Text =
DentistDataSet1.Tables(0).Rows(DropDownList1.SelectedIndex)("LastName")
txtFirstName.Text =
DentistDataSet1.Tables(0).Rows(DropDownList1.SelectedIndex)("FirstName")
End Sub
------
When I select a new DentistID, I got the following error:
------
Exception Details: System.IndexOutOfRangeException: There is no row at
position 1.
Source Error:
Line 182: 'txtLastName.DataBind()
Line 183: 'txtFirstName.DataBind()
Line 184: txtLastName.Text =
DentistDataSet1.Tables(0).Rows(DropDownList1.SelectedIndex)("LastName")
Line 185: txtFirstName.Text =
DentistDataSet1.Tables(0).Rows(DropDownList1.SelectedIndex)("FirstName")
Line 186:
------
Any one could help me to figure out the problem? Or what is the correct
steps to set up the properties and coding to get my expected result?
Thank you very much
David