You could simply store it in a session variable and retrieve it when
you need
across postbacks:
store:
Session("myvar") = myvar
retrieve:
myvar = Session("myvar")
Better anyway always to check if Nothing in case expired
If myvar IsNot Nothing Then
'...
Else
'Inform user
End If
Tommaso
Ben ha scritto:
[quoted text, click to view] > Hi,
>
> I need to use the value of a variable generated in the
> 'SelectedIndexChanged' event of a gridview in the 'RowUpdating' event.
> I tried this below, but the variable generated in the 'SelectedIndexChanged'
> event loses its value when starting the RowUpdating' event.
> I think it has something to do with the postback and so refreshing the page
> ...
>
> How can i do that?
> Thanks
> Ben
>
> the code:
>
> Friend myvar As String
>
> Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e
> As System.EventArgs) Handles GridView1.SelectedIndexChanged
> Dim row As GridViewRow = GridView1.SelectedRow
> myvar = row.Cells(2).Text 'this is ok
> end Sub
>
>
> Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
> GridView1.RowUpdating
> response.write(myvar) 'this gives nothing
Hi,
I need to use the value of a variable generated in the
'SelectedIndexChanged' event of a gridview in the 'RowUpdating' event.
I tried this below, but the variable generated in the 'SelectedIndexChanged'
event loses its value when starting the RowUpdating' event.
I think it has something to do with the postback and so refreshing the page
....
How can i do that?
Thanks
Ben
the code:
Friend myvar As String
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles GridView1.SelectedIndexChanged
Dim row As GridViewRow = GridView1.SelectedRow
myvar = row.Cells(2).Text 'this is ok
end Sub
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
GridView1.RowUpdating
response.write(myvar) 'this gives nothing
Thanks
<tommaso.gastaldi@uniroma1.it> schreef in bericht
news:1156032087.137098.251600@h48g2000cwc.googlegroups.com...
[quoted text, click to view] > You could simply store it in a session variable and retrieve it when
> you need
> across postbacks:
>
> store:
> Session("myvar") = myvar
>
> retrieve:
> myvar = Session("myvar")
>
> Better anyway always to check if Nothing in case expired
>
> If myvar IsNot Nothing Then
> '...
> Else
> 'Inform user
> End If
>
> Tommaso
>
> Ben ha scritto:
>
>> Hi,
>>
>> I need to use the value of a variable generated in the
>> 'SelectedIndexChanged' event of a gridview in the 'RowUpdating' event.
>> I tried this below, but the variable generated in the
>> 'SelectedIndexChanged'
>> event loses its value when starting the RowUpdating' event.
>> I think it has something to do with the postback and so refreshing the
>> page
>> ...
>>
>> How can i do that?
>> Thanks
>> Ben
>>
>> the code:
>>
>> Friend myvar As String
>>
>> Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object,
>> ByVal e
>> As System.EventArgs) Handles GridView1.SelectedIndexChanged
>> Dim row As GridViewRow = GridView1.SelectedRow
>> myvar = row.Cells(2).Text 'this is ok
>> end Sub
>>
>>
>> Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
>> System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
>> GridView1.RowUpdating
>> response.write(myvar) 'this gives nothing
>