|
-
May 17th, 2005, 04:51 AM
#1
Thread Starter
New Member
SelectedIndexChanged RESOLVED
Hi
I have a function "Private Sub fillBoxes(ByVal recordPos As Integer)" which fills several text boxes in the page with the contents of a database table row. RecordPos is the number of the row in the table.
I can call this function in the pageload with fillBoxes(0), or fillBoxes(4) or whatever and it works fine. However, I am trying to call it from the SelectedIndexChanged event of a DropDownList, like this:
Private Sub ddlKey_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlKey.SelectedIndexChanged
fillBoxes(ddlKey.SelectedIndex)
End Sub
So basically the user selects a value from the list and the textboxes are filled with the corresponding data row. This throws an exception, however, saying "There is no row at position X". There is nothing wrong with the function as it works fine when I call it in the page load.
Any ideas what could be wrong?
Thanks
Joe
Last edited by joef; May 17th, 2005 at 08:18 AM.
-
May 17th, 2005, 05:30 AM
#2
Re: SelectedIndexChanged
Set a breakpoint on that line of code. What value does SelectedIndex hold?
-
May 17th, 2005, 05:37 AM
#3
Thread Starter
New Member
Re: SelectedIndexChanged
Thanks for the reply. I set the breakpoint, and selected the fourth item on from the DropDownList. Since it is zero-based, the value of SelectedIndex should be 3, and it is. Since there are 30-odd records in the database table, 3 should be fine, in theory...?
-
May 17th, 2005, 05:43 AM
#4
Re: SelectedIndexChanged
Yes it should. Now go F11, into the function you made. Try following it until you get to the dataset's call based upon that index.
Try setting a quickwatch on the dataset too.
-
May 17th, 2005, 06:02 AM
#5
Thread Starter
New Member
Re: SelectedIndexChanged
Ok now this is weird. The function looks like this:
Private Sub fillBoxes(ByVal recordPos As Integer)
txtDesc.Text = DsAll1.HDSLMT(recordPos).DESCRIPTION
txtChoice1.Text = DsAll1.HDSLMT(recordPos).VALCHAR_1
txtChoice2.Text = DsAll1.HDSLMT(recordPos).VALCHAR_2
etc...
...
txtChoice9.Text = DsAll1.HDSLMT(recordPos).VALCHAR_9
txtDesc1.Text = DsAll1.HDSLMT(recordPos).VALTXT_1
txtDesc2.Text = DsAll1.HDSLMT(recordPos).VALTXT_2
etc...
...
txtDesc9.Text = DsAll1.HDSLMT(recordPos).VALTXT_9
End Sub
But none of those lines actually throw the exception. The exception is thrown at line 406, which is in a button click event handler, and that button hasn't even been clicked?!
I'm not a very experienced programmer and maybe I'm talking rubbish but to me that doesn't make sense.
-
May 17th, 2005, 06:31 AM
#6
Re: SelectedIndexChanged
And you used F11 to break in?
-
May 17th, 2005, 06:44 AM
#7
Thread Starter
New Member
Re: SelectedIndexChanged
In my understanding F11 is just a shortcut for start program.
-
May 17th, 2005, 07:02 AM
#8
Re: SelectedIndexChanged
Um... no, when you reach the line which calls the function you wrote, F11 will break into that function so you can follow the values being passed.
-
May 17th, 2005, 07:08 AM
#9
Thread Starter
New Member
Re: SelectedIndexChanged
I feel like I'm being really stupid here and just wasting your time. Sorry. This is a web application. I definitely should have said that at the start. All F11 does is alter the size of the browser window.
-
May 17th, 2005, 07:08 AM
#10
Addicted Member
Re: SelectedIndexChanged
by the way F8 will break into that function in my PC. so my advice is to double check
-
May 17th, 2005, 07:22 AM
#11
Thread Starter
New Member
Re: SelectedIndexChanged
Ahh, it's all clicked now 
I'll see what I can find by this method.
-
May 17th, 2005, 07:39 AM
#12
Thread Starter
New Member
Re: SelectedIndexChanged
Yep, I've fixed the problem now. Thanks a lot guys.
-
May 17th, 2005, 07:47 AM
#13
Re: SelectedIndexChanged
Add [Resolved] to the thread title. And perhaps tell us what the problem was.
-
May 17th, 2005, 08:21 AM
#14
Thread Starter
New Member
Re: SelectedIndexChanged RESOLVED
Ok, have done.
The problem was that immediately before calling the function, I needed to refill the dataset with the dataadapter. Otherwise, for some still unknown reason, it lost its records when the SelectedIndexChanged event occured.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|