Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I want to direct data from a datagrid to a label on the next page using Imagebutton.

What I have tried:

VB
Private Sub Imagebutton1_Click(ByVal sender As System.Object, _
    ByVal e As System.Web.UI.ImageClickEventArgs) _
	Handles Imagebutton1.Click

	Dim Row As GridViewRow = TryCast((CType(sender, ImageButton)) _
	    .Parent.Parent, GridViewRow)
	
	Dim y As Integer = 0
	Session("Value1") = (CType(DataGrid5.Items(y) _
	    .FindControl("INVOICE_B41"), Label)).Text

	'Session("Value2") = (CType(DataGrid5.Items(y) _
	    .FindControl("ValueOfColumns2"), Label)).Text

	Response.Redirect("letter.aspx")

End Sub
Posted
Updated 6-Nov-23 4:12am
v3
Comments
OriginalGriff 25-Oct-23 2:25am    
And?
What does it do that you didn't expect, or not do that you did?
What have you tried to do to find out why?
Are there any error messages, and if so, where and when? What did you do to make them happen?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.
yossef2023 25-Oct-23 2:46am    
You are correct, I am sorry
This error appeared
.............................
object reference not set to an instance of an object.
Graeme_Grant 25-Oct-23 3:27am    
Which line of code does the error occur on?

You are asking us for help, so you need to be specific. We cannot run your code.
Richard Deeming 25-Oct-23 3:29am    
Which simply means that you're trying to access a property of, or call a method of, something which is Nothing.

Since you haven't told us which line the error occurs on, we can't tell you which reference is Nothing. It could be Parent.Parent, DataGrid5, DataGrid5.Items(y), or the value returned from DataGrid5.Items(y).FindControl(...).

If you debug your code in Visual Studio, the exception helper will tell you precisely which reference caused the exception. Then you need to work out why it's Nothing when it shouldn't be.

We can't do any of that for you.
Member 15627495 25-Oct-23 6:19am    
to pipe a data to another Form, you can use :

- 'global var' they are define by the 'public' statement in VB.
put your 'public var' as first ( before all functions and subs ) at the top of the current class.
'public' make the var reachable for all your classes, and modules.

- by using 'function parameters' :
you can write a function sending values to another Form
private function send_to_form( values as object/what you want )
 dim Form2.the_var = values
Form2.load/show()
end function


- by using resources features
you can store values by resources features, look at it in your project 'setup'

VB have for sure others process to do it, but those 3 works well.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900