Checkbox = null, Specified cast is not valid.

Discussion in 'ASP .Net' started by =?Utf-8?B?cmtibmFpcg==?=, Oct 25, 2007.

  1. <edititemtemplate>
    <asp:CheckBox ID="giChkBox_bln_removed" runat="server" Checked='<%#
    Bind("bln_removed")%>'></asp:CheckBox>
    </edititemtemplate>

    The above line gives an error (Specified cast is not valid.) if the field
    bln_removed is null. Without changing the SQL select statement how can we fix
    this?
    =?Utf-8?B?cmtibmFpcg==?=, Oct 25, 2007
    #1
    1. Advertising

  2. On Oct 25, 10:58 pm, rkbnair <> wrote:
    > <edititemtemplate>
    > <asp:CheckBox ID="giChkBox_bln_removed" runat="server" Checked='<%#
    > Bind("bln_removed")%>'></asp:CheckBox>
    > </edititemtemplate>
    >
    > The above line gives an error (Specified cast is not valid.) if the field
    > bln_removed is null. Without changing the SQL select statement how can we fix
    > this?


    In C#:

    <%# Bind("bln_removed")==DBNull.Value ? "" : Bind("bln_removed") %>

    In VB.NET:

    <%# IIf(IsDBNull(Bind("bln_removed")), "", Bind("bln_removed")) %>
    Alexey Smirnov, Oct 25, 2007
    #2
    1. Advertising

  3. Thanks for the reply.

    I tried the C# code that you have given. It is still giving the same error.

    --
    test


    "Alexey Smirnov" wrote:

    > On Oct 25, 10:58 pm, rkbnair <> wrote:
    > > <edititemtemplate>
    > > <asp:CheckBox ID="giChkBox_bln_removed" runat="server" Checked='<%#
    > > Bind("bln_removed")%>'></asp:CheckBox>
    > > </edititemtemplate>
    > >
    > > The above line gives an error (Specified cast is not valid.) if the field
    > > bln_removed is null. Without changing the SQL select statement how can we fix
    > > this?

    >
    > In C#:
    >
    > <%# Bind("bln_removed")==DBNull.Value ? "" : Bind("bln_removed") %>
    >
    > In VB.NET:
    >
    > <%# IIf(IsDBNull(Bind("bln_removed")), "", Bind("bln_removed")) %>
    >
    >
    =?Utf-8?B?cmtibmFpcg==?=, Oct 25, 2007
    #3
  4. On Oct 26, 12:08 am, rkbnair <> wrote:
    > Thanks for the reply.
    >
    > I tried the C# code that you have given. It is still giving the same error.
    >


    Ah, I think it's not because of null, but because of "" in my code

    <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>
    Alexey Smirnov, Oct 25, 2007
    #4
  5. Alexey,

    I'm still getting the same error message.
    However, I tried the following code. It works. But the data is not updated
    when I save the GridView control.

    Checked='<%#
    (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart().TrimEnd()=="True"?true:false) %>'

    How can we make the data saved back to the database.
    --
    test


    "Alexey Smirnov" wrote:

    > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > Thanks for the reply.
    > >
    > > I tried the C# code that you have given. It is still giving the same error.
    > >

    >
    > Ah, I think it's not because of null, but because of "" in my code
    >
    > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>
    >
    >
    =?Utf-8?B?cmtibmFpcg==?=, Oct 26, 2007
    #5
  6. Alexey,
    I removed the excess spaces in between the characters. And it works now!!!

    Checked=<%#
    Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>

    Thank you very very much for the help.
    --
    test


    "rkbnair" wrote:

    > Alexey,
    >
    > I'm still getting the same error message.
    > However, I tried the following code. It works. But the data is not updated
    > when I save the GridView control.
    >
    > Checked='<%#
    > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart().TrimEnd()=="True"?true:false) %>'
    >
    > How can we make the data saved back to the database.
    > --
    > test
    >
    >
    > "Alexey Smirnov" wrote:
    >
    > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > Thanks for the reply.
    > > >
    > > > I tried the C# code that you have given. It is still giving the same error.
    > > >

    > >
    > > Ah, I think it's not because of null, but because of "" in my code
    > >
    > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>
    > >
    > >
    =?Utf-8?B?cmtibmFpcg==?=, Oct 26, 2007
    #6
  7. On Oct 26, 3:27 pm, rkbnair <> wrote:
    > Alexey,
    > I removed the excess spaces in between the characters. And it works now!!!
    >
    > Checked=<%#
    > Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>
    >
    > Thank you very very much for the help.
    > --
    > test
    >
    >
    >
    > "rkbnair" wrote:
    > > Alexey,

    >
    > > I'm still getting the same error message.
    > > However, I tried the following code. It works. But the data is not updated
    > > when I save the GridView control.

    >
    > > Checked='<%#
    > > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart(­).TrimEnd()=="True"?true:false) %>'

    >
    > > How can we make the data saved back to the database.
    > > --
    > > test

    >
    > > "Alexey Smirnov" wrote:

    >
    > > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > > Thanks for the reply.

    >
    > > > > I tried the C# code that you have given. It is still giving the same error.

    >
    > > > Ah, I think it's not because of null, but because of "" in my code

    >
    > > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>- Hide quoted text -

    >
    > - Show quoted text -


    Glad, that it works. The Checked property's value must be boolean,
    meaning it expects a value of either true or false and not spaces, or
    other extra characters...
    Alexey Smirnov, Oct 27, 2007
    #7
  8. Alexey,

    The error started appearing again. To my surprise, it was working before.

    <edititemtemplate>
    <asp:CheckBox ID="geChkBox_bln_core_asset" runat="server"
    Checked=<%#Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset")
    %>></asp:CheckBox>
    </edititemtemplate>

    --
    test


    "Alexey Smirnov" wrote:

    > On Oct 26, 3:27 pm, rkbnair <> wrote:
    > > Alexey,
    > > I removed the excess spaces in between the characters. And it works now!!!
    > >
    > > Checked=<%#
    > > Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>
    > >
    > > Thank you very very much for the help.
    > > --
    > > test
    > >
    > >
    > >
    > > "rkbnair" wrote:
    > > > Alexey,

    > >
    > > > I'm still getting the same error message.
    > > > However, I tried the following code. It works. But the data is not updated
    > > > when I save the GridView control.

    > >
    > > > Checked='<%#
    > > > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart(-).TrimEnd()=="True"?true:false) %>'

    > >
    > > > How can we make the data saved back to the database.
    > > > --
    > > > test

    > >
    > > > "Alexey Smirnov" wrote:

    > >
    > > > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > > > Thanks for the reply.

    > >
    > > > > > I tried the C# code that you have given. It is still giving the same error.

    > >
    > > > > Ah, I think it's not because of null, but because of "" in my code

    > >
    > > > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    > Glad, that it works. The Checked property's value must be boolean,
    > meaning it expects a value of either true or false and not spaces, or
    > other extra characters...
    >
    >
    =?Utf-8?B?cmtibmFpcg==?=, Oct 30, 2007
    #8
  9. On Oct 30, 5:29 pm, rkbnair <> wrote:
    > Alexey,
    >
    > The error started appearing again. To my surprise, it was working before.
    >
    > <edititemtemplate>
    > <asp:CheckBox ID="geChkBox_bln_core_asset" runat="server"
    > Checked=<%#Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset"­)
    > %>></asp:CheckBox>
    > </edititemtemplate>
    >
    > --
    > test
    >
    >
    >
    > "Alexey Smirnov" wrote:
    > > On Oct 26, 3:27 pm, rkbnair <> wrote:
    > > > Alexey,
    > > > I removed the excess spaces in between the characters. And it works now!!!

    >
    > > > Checked=<%#
    > > > Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>

    >
    > > > Thank you very very much for the help.
    > > > --
    > > > test

    >
    > > > "rkbnair" wrote:
    > > > > Alexey,

    >
    > > > > I'm still getting the same error message.
    > > > > However, I tried the following code. It works. But the data is not updated
    > > > > when I save the GridView control.

    >
    > > > > Checked='<%#
    > > > > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart(­-).TrimEnd()=="True"?true:false) %>'

    >
    > > > > How can we make the data saved back to the database.
    > > > > --
    > > > > test

    >
    > > > > "Alexey Smirnov" wrote:

    >
    > > > > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > > > > Thanks for the reply.

    >
    > > > > > > I tried the C# code that you have given. It is still giving the same error.

    >
    > > > > > Ah, I think it's not because of null, but because of "" in my code

    >
    > > > > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>- Hide quoted text -

    >
    > > > - Show quoted text -

    >
    > > Glad, that it works. The Checked property's value must be boolean,
    > > meaning it expects a value of either true or false and not spaces, or
    > > other extra characters...- Hide quoted text -

    >
    > - Show quoted text -


    Are you sure that it occurs exactly here? The code looks good.

    Try to delete

    Checked=<%#Bind("bln_core_asset")==DBNull.Value?
    false:Bind("bln_core_asset"­)

    to see if it helps
    Alexey Smirnov, Oct 30, 2007
    #9
  10. Yes, it appears at the same place.
    --
    test


    "Alexey Smirnov" wrote:

    > On Oct 30, 5:29 pm, rkbnair <> wrote:
    > > Alexey,
    > >
    > > The error started appearing again. To my surprise, it was working before.
    > >
    > > <edititemtemplate>
    > > <asp:CheckBox ID="geChkBox_bln_core_asset" runat="server"
    > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset"-)
    > > %>></asp:CheckBox>
    > > </edititemtemplate>
    > >
    > > --
    > > test
    > >
    > >
    > >
    > > "Alexey Smirnov" wrote:
    > > > On Oct 26, 3:27 pm, rkbnair <> wrote:
    > > > > Alexey,
    > > > > I removed the excess spaces in between the characters. And it works now!!!

    > >
    > > > > Checked=<%#
    > > > > Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>

    > >
    > > > > Thank you very very much for the help.
    > > > > --
    > > > > test

    > >
    > > > > "rkbnair" wrote:
    > > > > > Alexey,

    > >
    > > > > > I'm still getting the same error message.
    > > > > > However, I tried the following code. It works. But the data is not updated
    > > > > > when I save the GridView control.

    > >
    > > > > > Checked='<%#
    > > > > > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart(--).TrimEnd()=="True"?true:false) %>'

    > >
    > > > > > How can we make the data saved back to the database.
    > > > > > --
    > > > > > test

    > >
    > > > > > "Alexey Smirnov" wrote:

    > >
    > > > > > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > > > > > Thanks for the reply.

    > >
    > > > > > > > I tried the C# code that you have given. It is still giving the same error.

    > >
    > > > > > > Ah, I think it's not because of null, but because of "" in my code

    > >
    > > > > > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>- Hide quoted text -

    > >
    > > > > - Show quoted text -

    > >
    > > > Glad, that it works. The Checked property's value must be boolean,
    > > > meaning it expects a value of either true or false and not spaces, or
    > > > other extra characters...- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    > Are you sure that it occurs exactly here? The code looks good.
    >
    > Try to delete
    >
    > Checked=<%#Bind("bln_core_asset")==DBNull.Value?
    > false:Bind("bln_core_asset"-)
    >
    > to see if it helps
    >
    >
    =?Utf-8?B?cmtibmFpcg==?=, Oct 30, 2007
    #10
  11. On Oct 30, 8:38 pm, rkbnair <> wrote:
    > Yes, it appears at the same place.
    > --
    > test
    >
    >
    >
    > "Alexey Smirnov" wrote:
    > > On Oct 30, 5:29 pm, rkbnair <> wrote:
    > > > Alexey,

    >
    > > > The error started appearing again. To my surprise, it was working before.

    >
    > > > <edititemtemplate>
    > > > <asp:CheckBox ID="geChkBox_bln_core_asset" runat="server"
    > > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset"­-)
    > > > %>></asp:CheckBox>
    > > > </edititemtemplate>

    >
    > > > --
    > > > test

    >
    > > > "Alexey Smirnov" wrote:
    > > > > On Oct 26, 3:27 pm, rkbnair <> wrote:
    > > > > > Alexey,
    > > > > > I removed the excess spaces in between the characters. And it works now!!!

    >
    > > > > > Checked=<%#
    > > > > > Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>

    >
    > > > > > Thank you very very much for the help.
    > > > > > --
    > > > > > test

    >
    > > > > > "rkbnair" wrote:
    > > > > > > Alexey,

    >
    > > > > > > I'm still getting the same error message.
    > > > > > > However, I tried the following code. It works. But the data is not updated
    > > > > > > when I save the GridView control.

    >
    > > > > > > Checked='<%#
    > > > > > > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart(­--).TrimEnd()=="True"?true:false) %>'

    >
    > > > > > > How can we make the data saved back to the database.
    > > > > > > --
    > > > > > > test

    >
    > > > > > > "Alexey Smirnov" wrote:

    >
    > > > > > > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > > > > > > Thanks for the reply.

    >
    > > > > > > > > I tried the C# code that you have given. It is still giving the same error.

    >
    > > > > > > > Ah, I think it's not because of null, but because of "" in my code

    >
    > > > > > > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>- Hide quoted text -

    >
    > > > > > - Show quoted text -

    >
    > > > > Glad, that it works. The Checked property's value must be boolean,
    > > > > meaning it expects a value of either true or false and not spaces, or
    > > > > other extra characters...- Hide quoted text -

    >
    > > > - Show quoted text -

    >
    > > Are you sure that it occurs exactly here? The code looks good.

    >
    > > Try to delete

    >
    > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?
    > > false:Bind("bln_core_asset"-)

    >
    > > to see if it helps- Hide quoted text -

    >
    > - Show quoted text -


    wait... it's wrong, sure...

    Checked=<%# ( Bind("bln_core_asset")==DBNull.Value ? false :
    Bind("bln_core_asset"­) )%>

    it will not work without ( )
    Alexey Smirnov, Oct 30, 2007
    #11
  12. It, (), is giving compilation errors
    --
    test


    "Alexey Smirnov" wrote:

    > On Oct 30, 8:38 pm, rkbnair <> wrote:
    > > Yes, it appears at the same place.
    > > --
    > > test
    > >
    > >
    > >
    > > "Alexey Smirnov" wrote:
    > > > On Oct 30, 5:29 pm, rkbnair <> wrote:
    > > > > Alexey,

    > >
    > > > > The error started appearing again. To my surprise, it was working before.

    > >
    > > > > <edititemtemplate>
    > > > > <asp:CheckBox ID="geChkBox_bln_core_asset" runat="server"
    > > > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset"--)
    > > > > %>></asp:CheckBox>
    > > > > </edititemtemplate>

    > >
    > > > > --
    > > > > test

    > >
    > > > > "Alexey Smirnov" wrote:
    > > > > > On Oct 26, 3:27 pm, rkbnair <> wrote:
    > > > > > > Alexey,
    > > > > > > I removed the excess spaces in between the characters. And it works now!!!

    > >
    > > > > > > Checked=<%#
    > > > > > > Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>

    > >
    > > > > > > Thank you very very much for the help.
    > > > > > > --
    > > > > > > test

    > >
    > > > > > > "rkbnair" wrote:
    > > > > > > > Alexey,

    > >
    > > > > > > > I'm still getting the same error message.
    > > > > > > > However, I tried the following code. It works. But the data is not updated
    > > > > > > > when I save the GridView control.

    > >
    > > > > > > > Checked='<%#
    > > > > > > > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart(---).TrimEnd()=="True"?true:false) %>'

    > >
    > > > > > > > How can we make the data saved back to the database.
    > > > > > > > --
    > > > > > > > test

    > >
    > > > > > > > "Alexey Smirnov" wrote:

    > >
    > > > > > > > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > > > > > > > Thanks for the reply.

    > >
    > > > > > > > > > I tried the C# code that you have given. It is still giving the same error.

    > >
    > > > > > > > > Ah, I think it's not because of null, but because of "" in my code

    > >
    > > > > > > > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>- Hide quoted text -

    > >
    > > > > > > - Show quoted text -

    > >
    > > > > > Glad, that it works. The Checked property's value must be boolean,
    > > > > > meaning it expects a value of either true or false and not spaces, or
    > > > > > other extra characters...- Hide quoted text -

    > >
    > > > > - Show quoted text -

    > >
    > > > Are you sure that it occurs exactly here? The code looks good.

    > >
    > > > Try to delete

    > >
    > > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?
    > > > false:Bind("bln_core_asset"-)

    > >
    > > > to see if it helps- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    > wait... it's wrong, sure...
    >
    > Checked=<%# ( Bind("bln_core_asset")==DBNull.Value ? false :
    > Bind("bln_core_asset"-) )%>
    >
    > it will not work without ( )
    >
    >
    =?Utf-8?B?cmtibmFpcg==?=, Oct 30, 2007
    #12
  13. On Oct 30, 8:56 pm, rkbnair <> wrote:
    > It, (), is giving compilation errors
    > --
    > test
    >
    >
    >
    > "Alexey Smirnov" wrote:
    > > On Oct 30, 8:38 pm, rkbnair <> wrote:
    > > > Yes, it appears at the same place.
    > > > --
    > > > test

    >
    > > > "Alexey Smirnov" wrote:
    > > > > On Oct 30, 5:29 pm, rkbnair <> wrote:
    > > > > > Alexey,

    >
    > > > > > The error started appearing again. To my surprise, it was working before.

    >
    > > > > > <edititemtemplate>
    > > > > > <asp:CheckBox ID="geChkBox_bln_core_asset" runat="server"
    > > > > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset"­--)
    > > > > > %>></asp:CheckBox>
    > > > > > </edititemtemplate>

    >
    > > > > > --
    > > > > > test

    >
    > > > > > "Alexey Smirnov" wrote:
    > > > > > > On Oct 26, 3:27 pm, rkbnair <> wrote:
    > > > > > > > Alexey,
    > > > > > > > I removed the excess spaces in between the characters. And it works now!!!

    >
    > > > > > > > Checked=<%#
    > > > > > > > Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>

    >
    > > > > > > > Thank you very very much for the help.
    > > > > > > > --
    > > > > > > > test

    >
    > > > > > > > "rkbnair" wrote:
    > > > > > > > > Alexey,

    >
    > > > > > > > > I'm still getting the same error message.
    > > > > > > > > However, I tried the following code. It works. But the data is not updated
    > > > > > > > > when I save the GridView control.

    >
    > > > > > > > > Checked='<%#
    > > > > > > > > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart(­---).TrimEnd()=="True"?true:false) %>'

    >
    > > > > > > > > How can we make the data saved back to the database.
    > > > > > > > > --
    > > > > > > > > test

    >
    > > > > > > > > "Alexey Smirnov" wrote:

    >
    > > > > > > > > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > > > > > > > > Thanks for the reply.

    >
    > > > > > > > > > > I tried the C# code that you have given. It is still giving the same error.

    >
    > > > > > > > > > Ah, I think it's not because of null, but because of "" in my code

    >
    > > > > > > > > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>- Hide quoted text -

    >
    > > > > > > > - Show quoted text -

    >
    > > > > > > Glad, that it works. The Checked property's value must be boolean,
    > > > > > > meaning it expects a value of either true or false and not spaces, or
    > > > > > > other extra characters...- Hide quoted text -

    >
    > > > > > - Show quoted text -

    >
    > > > > Are you sure that it occurs exactly here? The code looks good.

    >
    > > > > Try to delete

    >
    > > > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?
    > > > > false:Bind("bln_core_asset"-)

    >
    > > > > to see if it helps- Hide quoted text -

    >
    > > > - Show quoted text -

    >
    > > wait... it's wrong, sure...

    >
    > > Checked=<%# ( Bind("bln_core_asset")==DBNull.Value ? false :
    > > Bind("bln_core_asset"-) )%>

    >
    > > it will not work without ( )- Hide quoted text -

    >
    > - Show quoted text -


    Look at the earlier posts, checked was with a value with ' ' around

    Checked='<%# ( Bind("bln_core_asset")==DBNull.Value ? false :
    Bind("bln_core_asset"­) )%>'
    Alexey Smirnov, Oct 31, 2007
    #13
  14. Alexey,

    I tried that as well. But no luck.

    --
    test


    "Alexey Smirnov" wrote:

    > On Oct 30, 8:56 pm, rkbnair <> wrote:
    > > It, (), is giving compilation errors
    > > --
    > > test
    > >
    > >
    > >
    > > "Alexey Smirnov" wrote:
    > > > On Oct 30, 8:38 pm, rkbnair <> wrote:
    > > > > Yes, it appears at the same place.
    > > > > --
    > > > > test

    > >
    > > > > "Alexey Smirnov" wrote:
    > > > > > On Oct 30, 5:29 pm, rkbnair <> wrote:
    > > > > > > Alexey,

    > >
    > > > > > > The error started appearing again. To my surprise, it was working before.

    > >
    > > > > > > <edititemtemplate>
    > > > > > > <asp:CheckBox ID="geChkBox_bln_core_asset" runat="server"
    > > > > > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset"---)
    > > > > > > %>></asp:CheckBox>
    > > > > > > </edititemtemplate>

    > >
    > > > > > > --
    > > > > > > test

    > >
    > > > > > > "Alexey Smirnov" wrote:
    > > > > > > > On Oct 26, 3:27 pm, rkbnair <> wrote:
    > > > > > > > > Alexey,
    > > > > > > > > I removed the excess spaces in between the characters. And it works now!!!

    > >
    > > > > > > > > Checked=<%#
    > > > > > > > > Bind("bln_core_asset")==DBNull.Value?false:Bind("bln_core_asset") %>

    > >
    > > > > > > > > Thank you very very much for the help.
    > > > > > > > > --
    > > > > > > > > test

    > >
    > > > > > > > > "rkbnair" wrote:
    > > > > > > > > > Alexey,

    > >
    > > > > > > > > > I'm still getting the same error message.
    > > > > > > > > > However, I tried the following code. It works. But the data is not updated
    > > > > > > > > > when I save the GridView control.

    > >
    > > > > > > > > > Checked='<%#
    > > > > > > > > > (DataBinder.Eval(Container.DataItem,"bln_core_asset").ToString().TrimStart(----).TrimEnd()=="True"?true:false) %>'

    > >
    > > > > > > > > > How can we make the data saved back to the database.
    > > > > > > > > > --
    > > > > > > > > > test

    > >
    > > > > > > > > > "Alexey Smirnov" wrote:

    > >
    > > > > > > > > > > On Oct 26, 12:08 am, rkbnair <> wrote:
    > > > > > > > > > > > Thanks for the reply.

    > >
    > > > > > > > > > > > I tried the C# code that you have given. It is still giving the same error.

    > >
    > > > > > > > > > > Ah, I think it's not because of null, but because of "" in my code

    > >
    > > > > > > > > > > <%# Bind("bln_removed")==DBNull.Value ? false : Bind("bln_removed") %>- Hide quoted text -

    > >
    > > > > > > > > - Show quoted text -

    > >
    > > > > > > > Glad, that it works. The Checked property's value must be boolean,
    > > > > > > > meaning it expects a value of either true or false and not spaces, or
    > > > > > > > other extra characters...- Hide quoted text -

    > >
    > > > > > > - Show quoted text -

    > >
    > > > > > Are you sure that it occurs exactly here? The code looks good.

    > >
    > > > > > Try to delete

    > >
    > > > > > Checked=<%#Bind("bln_core_asset")==DBNull.Value?
    > > > > > false:Bind("bln_core_asset"-)

    > >
    > > > > > to see if it helps- Hide quoted text -

    > >
    > > > > - Show quoted text -

    > >
    > > > wait... it's wrong, sure...

    > >
    > > > Checked=<%# ( Bind("bln_core_asset")==DBNull.Value ? false :
    > > > Bind("bln_core_asset"-) )%>

    > >
    > > > it will not work without ( )- Hide quoted text -

    > >
    > > - Show quoted text -

    >
    > Look at the earlier posts, checked was with a value with ' ' around
    >
    > Checked='<%# ( Bind("bln_core_asset")==DBNull.Value ? false :
    > Bind("bln_core_asset"-) )%>'
    >
    >
    =?Utf-8?B?cmtibmFpcg==?=, Oct 31, 2007
    #14
  15. Hi rkbnair,

    As for the problem here, it seems the "Bind(..)" expression is the cause.
    "Bind" is a bi-direction databinding keyword and which only support the
    following usage

    <%# Bind("columnname or propertyname") %>

    You can not use it as an normal expression(just like what you can use on
    "Eval" keyword).

    Therefore, for the case here, I suggest you consider the following means:

    1. provide a default value(false) for your datatable so as to avoid letting
    the ASP.NET databinding to handle DBNull Value

    2. Manually use code to do update(rather than use "Bind" keyword), you can
    still use "Eval" to display the value.

    How do you think?

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------

    >Lines: 109
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >Alexey,
    >
    >I tried that as well. But no luck.
    >
    >--
    >test
    >
    >
    >
    Steven Cheng[MSFT], Nov 1, 2007
    #15
  16. Hello Steven,

    I think I should handle the null value in the query itself.

    I used isnull(bln_core_asset,0),?,?,etc. in the query statement and it works
    fine.

    Thanks for the help.

    --
    test


    "Steven Cheng[MSFT]" wrote:

    > Hi rkbnair,
    >
    > As for the problem here, it seems the "Bind(..)" expression is the cause.
    > "Bind" is a bi-direction databinding keyword and which only support the
    > following usage
    >
    > <%# Bind("columnname or propertyname") %>
    >
    > You can not use it as an normal expression(just like what you can use on
    > "Eval" keyword).
    >
    > Therefore, for the case here, I suggest you consider the following means:
    >
    > 1. provide a default value(false) for your datatable so as to avoid letting
    > the ASP.NET databinding to handle DBNull Value
    >
    > 2. Manually use code to do update(rather than use "Bind" keyword), you can
    > still use "Eval" to display the value.
    >
    > How do you think?
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    > --------------------
    >
    > >Lines: 109
    > >Message-ID: <>
    > >Newsgroups: microsoft.public.dotnet.framework.aspnet
    > >NNTP-Posting-Host: tk2msftibfm01.phx.gbl 10.40.244.149
    > >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > >
    > >Alexey,
    > >
    > >I tried that as well. But no luck.
    > >
    > >--
    > >test
    > >
    > >
    > >

    >
    >
    =?Utf-8?B?cmtibmFpcg==?=, Nov 1, 2007
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ajit
    Replies:
    1
    Views:
    3,582
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
  2. Floela
    Replies:
    3
    Views:
    560
    Jon Skeet
    Jul 10, 2003
  3. Arjen
    Replies:
    1
    Views:
    7,756
    Carl Prothman [MVP]
    Aug 6, 2003
  4. Alan Silver
    Replies:
    5
    Views:
    2,573
    Kevin Spencer
    Feb 15, 2005
  5. Web learner
    Replies:
    5
    Views:
    19,649
    Web learner
    Apr 6, 2006
Loading...

Share This Page