M
Mich
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
<aspetailsView ID="DetailsView1" runat="server" ...
DataSourceID="SqlDataSource1" >
<Fields>
<asp:TemplateField HeaderText="myfield">
<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
.....
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
<aspetailsView ID="DetailsView1" runat="server" ...
DataSourceID="SqlDataSource1" >
<Fields>
<asp:TemplateField HeaderText="myfield">
</EditItemTemplate></asp:TextBox>
<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
.....