Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
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
Old 11-06-2003, 02:42 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,475
sde is on a distinguished road
hey jim,

i see a couple things wrong.

regarding your error:

it looks like you declared 'y', but did not instance it. try adding 'new' to the declaration.

Code:
Dim y As New System.Web.UI.WebControls.DataGridCommandEventArgs
however i think the logic here is wrong. if you are trying to do what the avr example does anyway.

in your vb.net example, you are passing in a variable named 'e' , and it looks like you are calling it with 'y'

i'm no vb expert ( more of a c# guy ) , and i'm not sure why you're passing vars in byval. try this:
Code:
Private Sub dgAttorney_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles dgAttorney.SelectedIndexChanged

  String X = e.CommandName

    Session("County") = e.Item.Cells(0).Text
    Session("AttNo") = e.Item.Cells(1).Text
    Response.Redirect("frmAttyDetail.aspx")

End Sub
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to connect to mssql using C++ ulrichshaman Platform/API C++ 5 09-14-2004 05:17 PM
MySql connect error message slappy Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 2 08-23-2004 07:02 PM
Filling a datagrid with BLOB data vinny MS Technologies ( ASP, VB, C#, .NET ) 2 08-18-2004 11:06 PM
mysqladmin: connect to server at 'localhost' failed infinite_root PHP 3 04-30-2004 06:50 AM
c++ gui with db connect sde Standard C, C++ 3 09-12-2002 12:22 PM


All times are GMT -8. The time now is 07:21 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting