Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specified argument out of the range -Embedded Gridview

Status
Not open for further replies.

lisat76

Programmer
Sep 25, 2007
89
US
I have a gridview(Gvpatientnm) that has another gridview embedded in it (gviewvisitdetailsinfo)

I have a sub that on the selected index changed that open a details view based on the gviewvisitdetailsinfo selected value in a modal pop up window.
I had this working, but it is erractic. I keep getting.

Specified argument was out of the range of valid values.
Parameter name: index

This all happens on selected indexchanged for the gviewvisitdetails grid

here is my code

Code:
   1. Protected Sub gvVisits_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)   
   2.         Dim row As GridViewRow  
   3.         For Each row In gvPatientsNM.Rows  
   4.             Dim gvVisit As GridView = CType(row.FindControl("gviewVisitDetailInfo"), GridView)  
   5.   
   6.              
   7.   
   8.             Dim varVisitid = gvVisit.SelectedValue  
   9.             odsVisitsEdit.SelectParameters("VisitID").DefaultValue = varVisitid  
  10.   
  11.               
  12.         Next  
  13.           
  14.         dviewVisitsEdit.DataBind()  
  15.         dviewVisitsEdit.ChangeMode(DetailsViewMode.Edit)  
  16.         ModalpopupVisits.Show()  
  17.     End Sub
 
it's telling me it for this line

dviewVisitsEdit.DataBind()

Even if I take that out I still get it.

I have narrowed down the issue a little further.
If I only have one row in my top level Gridview - gvpatientname it works fine.
If I have 2 rows in the gvpatientnm grid Then the selected row for the embedded gridview -gvvisitdetails
stays selected if I change from one patientname row to another. So the gvvisit could have two rows selected under two patients.

Let me try to illustrate

gvpatientnm

PatID Name
1 Joe Jones
gvvisitsDetails
PatID VisitID
1 1234
1 6783
then for another patient the gvpatiennm gridview and gvvisit gridview are repeated
gvpatientnm
2 Mike Johnson
gvvisitsDetails
PatID visitid
2 4747

Here's a link to a screen shot of the grid
<GridView Pics (opens in new window)

Notice how both edit buttons are able to be selected, this causes a problem when I try to send the selected value to
my detailsview - dvvisitedit.

I am not sure how the best way to handles this is??
Help is appreciated.
Thanks
 
Got it working

Code:
Dim gv As GridView = DirectCast(sender, GridView)
odsVisitsEdit.SelectParameters("VisitID").DefaultValue = gv.SelectedValue
dviewVisitsEdit.DataBind()
dviewVisitsEdit.ChangeMode(DetailsViewMode.Edit)
ModalpopupVisits.Show()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top