Home All Groups Group Topic Archive Search About
Author
31 Jul 2006 10:27 AM
stan
I have a user control where I defined a boolean property. I cannot set the
property in the code behind - the control is part of the Datagrid.  I tried
to pass the property the following way:
<aaa:MyControl runat="server" id="stan" IsReady="<%# booleanReady %>"/>
However, that does not work.  It looks like the "set" for the property does
not get executed.  However, it works if I hardcode "true" or "false".  I am
using .Net 1.1, VB. Can someone help?

TIA,
Stan

Author
31 Jul 2006 2:55 PM
Alessandro Zifiglio
hi Stan, i think what you are missing is the call to your pages DataBind
method. Call this method versus only calling your DataGrids databind method.
The following test works and i dont see why it shouldnt work for you.
eg.

Dim booleanReady As Boolean = True
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
        if (not ispostback) then
        DataGrid1.DataSource = CreateDataSource() ' to your datasource
        ' Note that following line is commented out
        'DataGrid1.DataBind()
        Me.DataBind()
        end if
    End Sub

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net

Show quoteHide quote
"stan" <sschnei***@bny.com> ha scritto nel messaggio
news:u$FK4vItGHA.1888@TK2MSFTNGP03.phx.gbl...
>I have a user control where I defined a boolean property. I cannot set the
> property in the code behind - the control is part of the Datagrid.  I
> tried
> to pass the property the following way:
> <aaa:MyControl runat="server" id="stan" IsReady="<%# booleanReady %>"/>
> However, that does not work.  It looks like the "set" for the property
> does
> not get executed.  However, it works if I hardcode "true" or "false".  I
> am
> using .Net 1.1, VB. Can someone help?
>
> TIA,
> Stan
>
Author
31 Jul 2006 3:00 PM
Alessandro Zifiglio
Stan, following is the come code i used to test under asp.net 1.1 :
Regards,
Alessandro Zifiglio
http://www.AsyncUI.net

Containing page .aspx :
<%@ Page Language="VB"%>
<html>
<head id="Head1">
  <title>Untitled Page</title>
  <script runat="server">
    Dim booleanReady As Boolean = True
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
        DataGrid1.DataSource = CreateDataSource()
        'DataGrid1.DataBind()
        Me.DataBind()
    End Sub
    Function CreateDataSource() As ICollection

         ' Create sample data for the DataList control.
         Dim dt As DataTable = New DataTable()
         Dim dr As DataRow

         ' Define the columns of the table.
         dt.Columns.Add(New DataColumn("BoolValue", GetType(Boolean)))

         ' Populate the table with sample values.
        dr = dt.NewRow()
  dr(0) = true
  dt.Rows.Add(dr)

  dr = dt.NewRow()
  dr(0) = false
  dt.Rows.Add(dr)

  dr = dt.NewRow()
  dr(0) = true
  dt.Rows.Add(dr)

         Dim dv As DataView = New DataView(dt)
         Return dv

      End Function

  </script>
</head>
<body>
  <form id="form1" runat="server">
   <div>
    <asp:DataGrid id="DataGrid1" runat="server">
    <Columns>
    <asp:TemplateColumn HeaderText="booleanReady">
    <ItemTemplate>
    <uc1:WebUserControlTest id="WebUserControlTest1" IsReady='<%#
booleanReady %>' runat="server">
    </uc1:WebUserControlTest>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>
   </div>
  </form>
</body>
</html>


your user control .ascx :
------------------------------
<%@ Control Language="VB"%>
<script runat="server">
    Private isReadyValue As Boolean = False
    Public Property IsReady() As Boolean
        Get
            Return isReadyValue
        End Get
        Set(ByVal value As Boolean)
            isReadyValue = value
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
            Label1.Text = IsReady.ToString()
    End Sub
</script>
<asp:Label id="Label1" runat="server"></asp:Label>
Show quoteHide quote
"Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha scritto
nel messaggio news:%23I3hSFLtGHA.4748@TK2MSFTNGP03.phx.gbl...
> hi Stan, i think what you are missing is the call to your pages DataBind
> method. Call this method versus only calling your DataGrids databind
> method. The following test works and i dont see why it shouldnt work for
> you.
> eg.
>
> Dim booleanReady As Boolean = True
>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
>        if (not ispostback) then
>        DataGrid1.DataSource = CreateDataSource() ' to your datasource
>        ' Note that following line is commented out
>        'DataGrid1.DataBind()
>        Me.DataBind()
>        end if
>    End Sub
>
> Regards,
> Alessandro Zifiglio
> http://www.AsyncUI.net
>
> "stan" <sschnei***@bny.com> ha scritto nel messaggio
> news:u$FK4vItGHA.1888@TK2MSFTNGP03.phx.gbl...
>>I have a user control where I defined a boolean property. I cannot set the
>> property in the code behind - the control is part of the Datagrid.  I
>> tried
>> to pass the property the following way:
>> <aaa:MyControl runat="server" id="stan" IsReady="<%# booleanReady %>"/>
>> However, that does not work.  It looks like the "set" for the property
>> does
>> not get executed.  However, it works if I hardcode "true" or "false".  I
>> am
>> using .Net 1.1, VB. Can someone help?
>>
>> TIA,
>> Stan
>>
>
>
Author
31 Jul 2006 4:35 PM
Stan
Allessandro,
        this is alomost the same thing I do.  All works if the variable is
assigned a value that does not change.  However, I set the value based on
a condition.  it happens just before the bind.  It looks like the "set"
is bypassed.  I do the debug statement inside the "set" - it works only
when the value is hardcoded or defined in the code and not changed.

Stan

Show quoteHide quote
"Alessandro Zifiglio" <AlessandroZifiglio @  -h-o-t-m-a-i-l-c-o-m> wrote
in news:OVOufILtGHA.2260@TK2MSFTNGP02.phx.gbl:

> Stan, following is the come code i used to test under asp.net 1.1 :
> Regards,
> Alessandro Zifiglio
> http://www.AsyncUI.net
>
> Containing page .aspx :
> <%@ Page Language="VB"%>
> <html>
>  <head id="Head1">
>   <title>Untitled Page</title>
>   <script runat="server">
>     Dim booleanReady As Boolean = True
>     Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
>         DataGrid1.DataSource = CreateDataSource()
>         'DataGrid1.DataBind()
>         Me.DataBind()
>     End Sub
>     Function CreateDataSource() As ICollection
>
>          ' Create sample data for the DataList control.
>          Dim dt As DataTable = New DataTable()
>          Dim dr As DataRow
>
>          ' Define the columns of the table.
>          dt.Columns.Add(New DataColumn("BoolValue", GetType(Boolean)))
>
>          ' Populate the table with sample values.
>         dr = dt.NewRow()
>   dr(0) = true
>   dt.Rows.Add(dr)
>
>   dr = dt.NewRow()
>   dr(0) = false
>   dt.Rows.Add(dr)
>
>   dr = dt.NewRow()
>   dr(0) = true
>   dt.Rows.Add(dr)
>
>          Dim dv As DataView = New DataView(dt)
>          Return dv
>
>       End Function
>
>   </script>
>  </head>
>  <body>
>   <form id="form1" runat="server">
>    <div>
>     <asp:DataGrid id="DataGrid1" runat="server">
>     <Columns>
>     <asp:TemplateColumn HeaderText="booleanReady">
>     <ItemTemplate>
>     <uc1:WebUserControlTest id="WebUserControlTest1" IsReady='<%#
> booleanReady %>' runat="server">
>     </uc1:WebUserControlTest>
>     </ItemTemplate>
>     </asp:TemplateColumn>
>     </Columns>
>     </asp:DataGrid>
>    </div>
>   </form>
>  </body>
> </html>
>
>
> your user control .ascx :
> ------------------------------
> <%@ Control Language="VB"%>
> <script runat="server">
>     Private isReadyValue As Boolean = False
>     Public Property IsReady() As Boolean
>         Get
>             Return isReadyValue
>         End Get
>         Set(ByVal value As Boolean)
>             isReadyValue = value
>         End Set
>     End Property
>
>     Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
>             Label1.Text = IsReady.ToString()
>     End Sub
> </script>
> <asp:Label id="Label1" runat="server"></asp:Label>
> "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha
> scritto nel messaggio news:%23I3hSFLtGHA.4748@TK2MSFTNGP03.phx.gbl...
>> hi Stan, i think what you are missing is the call to your pages
>> DataBind method. Call this method versus only calling your DataGrids
>> databind method. The following test works and i dont see why it
>> shouldnt work for you.
>> eg.
>>
>> Dim booleanReady As Boolean = True
>>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>>        if (not ispostback) then
>>        DataGrid1.DataSource = CreateDataSource() ' to your datasource
>>        ' Note that following line is commented out
>>        'DataGrid1.DataBind()
>>        Me.DataBind()
>>        end if
>>    End Sub
>>
>> Regards,
>> Alessandro Zifiglio
>> http://www.AsyncUI.net
>>
>> "stan" <sschnei***@bny.com> ha scritto nel messaggio
>> news:u$FK4vItGHA.1888@TK2MSFTNGP03.phx.gbl...
>>>I have a user control where I defined a boolean property. I cannot
>>>set the
>>> property in the code behind - the control is part of the Datagrid.
>>> I tried
>>> to pass the property the following way:
>>> <aaa:MyControl runat="server" id="stan" IsReady="<%# booleanReady
>>> %>"/> However, that does not work.  It looks like the "set" for the
>>> property does
>>> not get executed.  However, it works if I hardcode "true" or
>>> "false".  I am
>>> using .Net 1.1, VB. Can someone help?
>>>
>>> TIA,
>>> Stan
>>>
>>
>>
>
>
>
Author
31 Jul 2006 8:52 PM
Stan
Never mind.  Thanks for your help.  I figured it out.  User error.
Stan

Stan <noem***@please.com> wrote in
Show quoteHide quote
news:eD3UX9LtGHA.4252@TK2MSFTNGP02.phx.gbl:

> Allessandro,
>          this is alomost the same thing I do.  All works if the
>          variable is
> assigned a value that does not change.  However, I set the value based
> on a condition.  it happens just before the bind.  It looks like the
> "set" is bypassed.  I do the debug statement inside the "set" - it
> works only when the value is hardcoded or defined in the code and not
> changed.
>
> Stan
>
> "Alessandro Zifiglio" <AlessandroZifiglio @  -h-o-t-m-a-i-l-c-o-m>
> wrote in news:OVOufILtGHA.2260@TK2MSFTNGP02.phx.gbl:
>
>> Stan, following is the come code i used to test under asp.net 1.1 :
>> Regards,
>> Alessandro Zifiglio
>> http://www.AsyncUI.net
>>
>> Containing page .aspx :
>> <%@ Page Language="VB"%>
>> <html>
>>  <head id="Head1">
>>   <title>Untitled Page</title>
>>   <script runat="server">
>>     Dim booleanReady As Boolean = True
>>     Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>>         DataGrid1.DataSource = CreateDataSource()
>>         'DataGrid1.DataBind()
>>         Me.DataBind()
>>     End Sub
>>     Function CreateDataSource() As ICollection
>>
>>          ' Create sample data for the DataList control.
>>          Dim dt As DataTable = New DataTable()
>>          Dim dr As DataRow
>>
>>          ' Define the columns of the table.
>>          dt.Columns.Add(New DataColumn("BoolValue",
>>          GetType(Boolean)))
>>
>>          ' Populate the table with sample values.
>>         dr = dt.NewRow()
>>   dr(0) = true
>>   dt.Rows.Add(dr)
>>
>>   dr = dt.NewRow()
>>   dr(0) = false
>>   dt.Rows.Add(dr)
>>
>>   dr = dt.NewRow()
>>   dr(0) = true
>>   dt.Rows.Add(dr)
>>
>>          Dim dv As DataView = New DataView(dt)
>>          Return dv
>>
>>       End Function
>>
>>   </script>
>>  </head>
>>  <body>
>>   <form id="form1" runat="server">
>>    <div>
>>     <asp:DataGrid id="DataGrid1" runat="server">
>>     <Columns>
>>     <asp:TemplateColumn HeaderText="booleanReady">
>>     <ItemTemplate>
>>     <uc1:WebUserControlTest id="WebUserControlTest1" IsReady='<%#
>> booleanReady %>' runat="server">
>>     </uc1:WebUserControlTest>
>>     </ItemTemplate>
>>     </asp:TemplateColumn>
>>     </Columns>
>>     </asp:DataGrid>
>>    </div>
>>   </form>
>>  </body>
>> </html>
>>
>>
>> your user control .ascx :
>> ------------------------------
>> <%@ Control Language="VB"%>
>> <script runat="server">
>>     Private isReadyValue As Boolean = False
>>     Public Property IsReady() As Boolean
>>         Get
>>             Return isReadyValue
>>         End Get
>>         Set(ByVal value As Boolean)
>>             isReadyValue = value
>>         End Set
>>     End Property
>>
>>     Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs)
>>             Label1.Text = IsReady.ToString()
>>     End Sub
>> </script>
>> <asp:Label id="Label1" runat="server"></asp:Label>
>> "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha
>> scritto nel messaggio news:%23I3hSFLtGHA.4748@TK2MSFTNGP03.phx.gbl...
>>> hi Stan, i think what you are missing is the call to your pages
>>> DataBind method. Call this method versus only calling your DataGrids
>>> databind method. The following test works and i dont see why it
>>> shouldnt work for you.
>>> eg.
>>>
>>> Dim booleanReady As Boolean = True
>>>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>> System.EventArgs)
>>>        if (not ispostback) then
>>>        DataGrid1.DataSource = CreateDataSource() ' to your
>>>        datasource ' Note that following line is commented out
>>>        'DataGrid1.DataBind()
>>>        Me.DataBind()
>>>        end if
>>>    End Sub
>>>
>>> Regards,
>>> Alessandro Zifiglio
>>> http://www.AsyncUI.net
>>>
>>> "stan" <sschnei***@bny.com> ha scritto nel messaggio
>>> news:u$FK4vItGHA.1888@TK2MSFTNGP03.phx.gbl...
>>>>I have a user control where I defined a boolean property. I cannot
>>>>set the
>>>> property in the code behind - the control is part of the Datagrid.
>>>> I tried
>>>> to pass the property the following way:
>>>> <aaa:MyControl runat="server" id="stan" IsReady="<%# booleanReady
>>>> %>"/> However, that does not work.  It looks like the "set" for the
>>>> property does
>>>> not get executed.  However, it works if I hardcode "true" or
>>>> "false".  I am
>>>> using .Net 1.1, VB. Can someone help?
>>>>
>>>> TIA,
>>>> Stan
>>>>
>>>
>>>
>>
>>
>>
>
>
Author
31 Jul 2006 8:58 PM
Alessandro Zifiglio
your welcome stan,

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net

Show quoteHide quote
"Stan" <noem***@please.com> ha scritto nel messaggio
news:udBhJNOtGHA.4080@TK2MSFTNGP03.phx.gbl...
> Never mind.  Thanks for your help.  I figured it out.  User error.
> Stan
>
> Stan <noem***@please.com> wrote in
> news:eD3UX9LtGHA.4252@TK2MSFTNGP02.phx.gbl:
>
>> Allessandro,
>>          this is alomost the same thing I do.  All works if the
>>          variable is
>> assigned a value that does not change.  However, I set the value based
>> on a condition.  it happens just before the bind.  It looks like the
>> "set" is bypassed.  I do the debug statement inside the "set" - it
>> works only when the value is hardcoded or defined in the code and not
>> changed.
>>
>> Stan
>>
>> "Alessandro Zifiglio" <AlessandroZifiglio @  -h-o-t-m-a-i-l-c-o-m>
>> wrote in news:OVOufILtGHA.2260@TK2MSFTNGP02.phx.gbl:
>>
>>> Stan, following is the come code i used to test under asp.net 1.1 :
>>> Regards,
>>> Alessandro Zifiglio
>>> http://www.AsyncUI.net
>>>
>>> Containing page .aspx :
>>> <%@ Page Language="VB"%>
>>> <html>
>>>  <head id="Head1">
>>>   <title>Untitled Page</title>
>>>   <script runat="server">
>>>     Dim booleanReady As Boolean = True
>>>     Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>> System.EventArgs)
>>>         DataGrid1.DataSource = CreateDataSource()
>>>         'DataGrid1.DataBind()
>>>         Me.DataBind()
>>>     End Sub
>>>     Function CreateDataSource() As ICollection
>>>
>>>          ' Create sample data for the DataList control.
>>>          Dim dt As DataTable = New DataTable()
>>>          Dim dr As DataRow
>>>
>>>          ' Define the columns of the table.
>>>          dt.Columns.Add(New DataColumn("BoolValue",
>>>          GetType(Boolean)))
>>>
>>>          ' Populate the table with sample values.
>>>         dr = dt.NewRow()
>>>   dr(0) = true
>>>   dt.Rows.Add(dr)
>>>
>>>   dr = dt.NewRow()
>>>   dr(0) = false
>>>   dt.Rows.Add(dr)
>>>
>>>   dr = dt.NewRow()
>>>   dr(0) = true
>>>   dt.Rows.Add(dr)
>>>
>>>          Dim dv As DataView = New DataView(dt)
>>>          Return dv
>>>
>>>       End Function
>>>
>>>   </script>
>>>  </head>
>>>  <body>
>>>   <form id="form1" runat="server">
>>>    <div>
>>>     <asp:DataGrid id="DataGrid1" runat="server">
>>>     <Columns>
>>>     <asp:TemplateColumn HeaderText="booleanReady">
>>>     <ItemTemplate>
>>>     <uc1:WebUserControlTest id="WebUserControlTest1" IsReady='<%#
>>> booleanReady %>' runat="server">
>>>     </uc1:WebUserControlTest>
>>>     </ItemTemplate>
>>>     </asp:TemplateColumn>
>>>     </Columns>
>>>     </asp:DataGrid>
>>>    </div>
>>>   </form>
>>>  </body>
>>> </html>
>>>
>>>
>>> your user control .ascx :
>>> ------------------------------
>>> <%@ Control Language="VB"%>
>>> <script runat="server">
>>>     Private isReadyValue As Boolean = False
>>>     Public Property IsReady() As Boolean
>>>         Get
>>>             Return isReadyValue
>>>         End Get
>>>         Set(ByVal value As Boolean)
>>>             isReadyValue = value
>>>         End Set
>>>     End Property
>>>
>>>     Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>> System.EventArgs)
>>>             Label1.Text = IsReady.ToString()
>>>     End Sub
>>> </script>
>>> <asp:Label id="Label1" runat="server"></asp:Label>
>>> "Alessandro Zifiglio" <AlessandroZifiglio @ -h-o-t-m-a-i-l-c-o-m> ha
>>> scritto nel messaggio news:%23I3hSFLtGHA.4748@TK2MSFTNGP03.phx.gbl...
>>>> hi Stan, i think what you are missing is the call to your pages
>>>> DataBind method. Call this method versus only calling your DataGrids
>>>> databind method. The following test works and i dont see why it
>>>> shouldnt work for you.
>>>> eg.
>>>>
>>>> Dim booleanReady As Boolean = True
>>>>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>> System.EventArgs)
>>>>        if (not ispostback) then
>>>>        DataGrid1.DataSource = CreateDataSource() ' to your
>>>>        datasource ' Note that following line is commented out
>>>>        'DataGrid1.DataBind()
>>>>        Me.DataBind()
>>>>        end if
>>>>    End Sub
>>>>
>>>> Regards,
>>>> Alessandro Zifiglio
>>>> http://www.AsyncUI.net
>>>>
>>>> "stan" <sschnei***@bny.com> ha scritto nel messaggio
>>>> news:u$FK4vItGHA.1888@TK2MSFTNGP03.phx.gbl...
>>>>>I have a user control where I defined a boolean property. I cannot
>>>>>set the
>>>>> property in the code behind - the control is part of the Datagrid.
>>>>> I tried
>>>>> to pass the property the following way:
>>>>> <aaa:MyControl runat="server" id="stan" IsReady="<%# booleanReady
>>>>> %>"/> However, that does not work.  It looks like the "set" for the
>>>>> property does
>>>>> not get executed.  However, it works if I hardcode "true" or
>>>>> "false".  I am
>>>>> using .Net 1.1, VB. Can someone help?
>>>>>
>>>>> TIA,
>>>>> Stan
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>