DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
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:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us