View Single Post
Old 11-06-2003, 10:45 AM   #1 (permalink)
wvjim
Registered User
 
Join Date: Nov 2003
Location: Charleston, West Virginia
Posts: 1
wvjim is on a distinguished road
Send a message via AIM to wvjim
Connect from DataGrid to Detail

I am trying to attach from a DataGrid to a detail page using VB.net. I have an example from AVR but have been unsuccessful at converting that to the VB platform.

I am displaying a list of attorneys in the grid with the intent of selecting an individual attorney and making modifications to that single record (address, etc.)

This is the AVR code that attaches from the grid to the detail:
Code:
BegSr dgCust_ItemCommand Access(*Private) Event(*this.dgCust.ItemCommand)
  DclSrParm source Type(*Object)
  DclSrParm e Type(System.Web.UI.WebControls.DataGridCommandEventArgs)
		
  DclFld X Type(*String)
  X = e.CommandName
  // You can only get data out of a bound column
  If X =( "NEILYOUNG")
    // Get the customer number out of the 0th column
    Session("CUSTNO") = e.Item.Cells(0).Text     // Fetch the value for the customer number which is the first item on the row
    Response.Redirect("CustomerUpdate.aspx")
  EndIf
		
  EndSr
Here is the code I've place withing my VB program:
Code:
Private Sub dgAttorney_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgAttorney.SelectedIndexChanged

  Dim source As Object
  Dim y As System.Web.UI.WebControls.DataGridCommandEventArgs
  Dim X As String
  ' X = y.CommandName
  Session("County") = y.Item.Cells(0).Text
  Session("AttNo") = y.Item.Cells(1).Text
  Response.Redirect("frmAttyDetail.aspx")

End Sub
When I run the VB process I get the following error message:

Server Error in '/AttorneyMaintenance' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 117: Dim X As String
Line 118: ' X = y.CommandName
Line 119: Session("County") = y.Item.Cells(0).Text
Line 120: Session("AttNo") = y.Item.Cells(1).Text
Line 121: Response.Redirect("frmAttyDetail.aspx")


Source File: c:\inetpub\wwwroot\AttorneyMaintenance\frmAttyList .aspx.vb Line: 119

I sure could use some help with this.

Thanks in advance...Jim Seering:rock:
wvjim is offline   Reply With Quote