|
|
|
start date: Wed, 15 Aug 2007 17:49:45 +0200,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Mich
|
|
2
Sergey Poberezovskiy
|
|
3
Mich
|
variable lost between DetailsView1_DataBound and DetailsView1_ItemCreated
Hi,
I need the value of one field in the detailsview (in normal mode) in order
to make a test when creating items.
I get that value, put it into a friend variable, but when fetching it from
the ItemCreated event, it's empty.
Why does it lose its value and how to solve that?
Thanks for help
Mich
<asp:DetailsView ID="DetailsView1" runat="server" ...
DataSourceID="SqlDataSource1" >
<Fields>
<asp:TemplateField HeaderText="myfield">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("myfield") %>'
></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("myfield")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</fields>
code-behind:
------------
.....
Friend st As string
.....
Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.DataBound
If DetailsView1.CurrentMode = DetailsViewMode.ReadOnly Then
Dim dvr As DetailsViewRow
Dim lb1 As String
For Each dvr In DetailsView1.Rows
lb1 = CType(dvr.FindControl("label1"), Label)
Next
st=lb1.text
End If
response.write(st) 'this works
End Sub
Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles DetailsView1.ItemCreated
if st="ok" then 'st is empty
.....
Date:Wed, 15 Aug 2007 17:49:45 +0200
Author:
|
RE: variable lost between DetailsView1_DataBound and DetailsView1_Item
Mich,
AFAIK, ItemCreated is fired PRIOR to DataBound event - therefore at the time
you are trying to read it is is not set yet
"Mich" wrote:
> Hi,
>
> I need the value of one field in the detailsview (in normal mode) in order
> to make a test when creating items.
> I get that value, put it into a friend variable, but when fetching it from
> the ItemCreated event, it's empty.
> Why does it lose its value and how to solve that?
>
> Thanks for help
> Mich
>
> <asp:DetailsView ID="DetailsView1" runat="server" ...
> DataSourceID="SqlDataSource1" >
> <Fields>
> <asp:TemplateField HeaderText="myfield">
> <EditItemTemplate>
> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("myfield") %>'
> ></asp:TextBox>
> </EditItemTemplate>
> <ItemTemplate>
> <asp:Label ID="Label1" runat="server" Text='<%# Bind("myfield")
> %>'></asp:Label>
> </ItemTemplate>
> </asp:TemplateField>
> </fields>
>
>
> code-behind:
> ------------
> .....
> Friend st As string
> .....
> Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles DetailsView1.DataBound
> If DetailsView1.CurrentMode = DetailsViewMode.ReadOnly Then
> Dim dvr As DetailsViewRow
> Dim lb1 As String
> For Each dvr In DetailsView1.Rows
> lb1 = CType(dvr.FindControl("label1"), Label)
> Next
> st=lb1.text
> End If
> response.write(st) 'this works
> End Sub
>
> Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles DetailsView1.ItemCreated
>
> if st="ok" then 'st is empty
> .....
>
>
>
>
Date:Wed, 15 Aug 2007 17:44:04 -0700
Author:
|
Re: variable lost between DetailsView1_DataBound and DetailsView1_Item
Thanks
"Sergey Poberezovskiy"
schreef in bericht
news:5C154F51-3337-4A19-8EDC-823729AC6167@microsoft.com...
> Mich,
>
> AFAIK, ItemCreated is fired PRIOR to DataBound event - therefore at the
> time
> you are trying to read it is is not set yet
>
> "Mich" wrote:
>
>> Hi,
>>
>> I need the value of one field in the detailsview (in normal mode) in
>> order
>> to make a test when creating items.
>> I get that value, put it into a friend variable, but when fetching it
>> from
>> the ItemCreated event, it's empty.
>> Why does it lose its value and how to solve that?
>>
>> Thanks for help
>> Mich
>>
>> <asp:DetailsView ID="DetailsView1" runat="server" ...
>> DataSourceID="SqlDataSource1" >
>> <Fields>
>> <asp:TemplateField HeaderText="myfield">
>> <EditItemTemplate>
>> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("myfield") %>'
>> ></asp:TextBox>
>> </EditItemTemplate>
>> <ItemTemplate>
>> <asp:Label ID="Label1" runat="server" Text='<%# Bind("myfield")
>> %>'></asp:Label>
>> </ItemTemplate>
>> </asp:TemplateField>
>> </fields>
>>
>>
>> code-behind:
>> ------------
>> .....
>> Friend st As string
>> .....
>> Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles DetailsView1.DataBound
>> If DetailsView1.CurrentMode = DetailsViewMode.ReadOnly Then
>> Dim dvr As DetailsViewRow
>> Dim lb1 As String
>> For Each dvr In DetailsView1.Rows
>> lb1 = CType(dvr.FindControl("label1"), Label)
>> Next
>> st=lb1.text
>> End If
>> response.write(st) 'this works
>> End Sub
>>
>> Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles DetailsView1.ItemCreated
>>
>> if st="ok" then 'st is empty
>> .....
>>
>>
>>
>>
Date:Thu, 16 Aug 2007 14:36:01 +0200
Author:
|
|
|