Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
TJ #1
Databinder.Eval passed as argument is choking
I have a datagrid that has a boolean column. The sql data is a bit stored
as a 1 or 0. Doing a straight up DataBinder.Eval(Container.DataItem,
"MyColumn") displays a "True" or "False" in the grid. No problems here.
What I want is for it to display a "Yes" or "No". So I'm using a
TemplateColumn instead of a BoundColumn so I can pass the value into a
function and return a string that says Yes or No. My problem is that the
function won't take the value seemingly no matter how I cast or don't cast
the argument when I send or in the receiving mechanism of the function.
In the aspx page:
<asp:TemplateColumn HeaderText="Approved">
<ItemTemplate>
<%# FormatYesOrNo(DataBinder.Eval(Container.DataItem, "MyBitColumn")) %>
</ItemTemplate>
</asp:TemplateColumn>
In the code behind:
public string FormatYesOrNo(bool x)
{
string z = "Yes";
if (x != true)
z = "No";
return z;
}
I tried casting the late bound info the aspx to a bool (e.g.
(bool)DataBinder.Eval...), but that didn't work. I tried changing the
FormatYesOrNo(bool x) in the code behind to FormatYesOrNo(string x) and
changing the guts accordingly, but that didn't work.
Any help appreciated.
-TJ
TJ Guest
-
Setting Visible with Databinder.Eval
Hi, I hope this is the right forum for my question. I have a Repeater control in which I have two panels. Only one panel should be visible at a... -
Handling Nulls in Databinder.Eval
I had a problem, now it's fixed, and now I have a concern on why isn't there a better way. The question is: How do you handle NULLs in your control... -
DataGrid - DataBinder.Eval
I am using a Datagrid and am populating the column header which is being picked up from a database. My problem is that if the column name conatins... -
Complete syntax of DataBinder.Eval() ?
I've been using DataBinder.Eval(container, expression, format) to late-bind controls in an aspx template with a typed dataset, but finding the... -
DataBinder.Eval Problem
Hi Use <%#DataBinder.Eval(Container.DataItem, "cat1") %> HTH Prasad "Frosty" <programmerx2002x@aol.com> wrote in message -
Elton Wang #2
Re: Databinder.Eval passed as argument is choking
Try following:
<asp:TemplateColumn HeaderText="Approved">
<ItemTemplate>
<%# (DataBinder.Eval(Container.DataItem, "MyBitColumn")) ? "Yes" : "No" %>
</ItemTemplate>
</asp:TemplateColumn>
HTH
"TJ" <teejay@newsgroups.nospam> wrote in message
news:%23Mtyo7azFHA.3408@TK2MSFTNGP09.phx.gbl...>I have a datagrid that has a boolean column. The sql data is a bit stored
>as a 1 or 0. Doing a straight up DataBinder.Eval(Container.DataItem,
>"MyColumn") displays a "True" or "False" in the grid. No problems here.
>
> What I want is for it to display a "Yes" or "No". So I'm using a
> TemplateColumn instead of a BoundColumn so I can pass the value into a
> function and return a string that says Yes or No. My problem is that the
> function won't take the value seemingly no matter how I cast or don't cast
> the argument when I send or in the receiving mechanism of the function.
>
> In the aspx page:
>
> <asp:TemplateColumn HeaderText="Approved">
> <ItemTemplate>
> <%# FormatYesOrNo(DataBinder.Eval(Container.DataItem, "MyBitColumn")) %>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> In the code behind:
> public string FormatYesOrNo(bool x)
> {
> string z = "Yes";
> if (x != true)
> z = "No";
> return z;
> }
>
> I tried casting the late bound info the aspx to a bool (e.g.
> (bool)DataBinder.Eval...), but that didn't work. I tried changing the
> FormatYesOrNo(bool x) in the code behind to FormatYesOrNo(string x) and
> changing the guts accordingly, but that didn't work.
>
> Any help appreciated.
>
> -TJ
>
>
>
>
>
Elton Wang Guest
-
TJ #3
Re: Databinder.Eval passed as argument is choking
I get this now:
"CS0029: Cannot implicitly convert type 'object' to 'bool'"
Seems closer. Thought it was a bool to begin with. I'm just reading a bit
datatype column from a SQL Server 2K table.
"Elton Wang" <elton_wang@hotmail.com> wrote in message
news:%23gLpaQbzFHA.3892@TK2MSFTNGP12.phx.gbl...> Try following:
>
> <asp:TemplateColumn HeaderText="Approved">
> <ItemTemplate>
> <%# (DataBinder.Eval(Container.DataItem, "MyBitColumn")) ? "Yes" : "No" %>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> HTH
>
> "TJ" <teejay@newsgroups.nospam> wrote in message
> news:%23Mtyo7azFHA.3408@TK2MSFTNGP09.phx.gbl...>>>I have a datagrid that has a boolean column. The sql data is a bit stored
>>as a 1 or 0. Doing a straight up DataBinder.Eval(Container.DataItem,
>>"MyColumn") displays a "True" or "False" in the grid. No problems here.
>>
>> What I want is for it to display a "Yes" or "No". So I'm using a
>> TemplateColumn instead of a BoundColumn so I can pass the value into a
>> function and return a string that says Yes or No. My problem is that the
>> function won't take the value seemingly no matter how I cast or don't
>> cast the argument when I send or in the receiving mechanism of the
>> function.
>>
>> In the aspx page:
>>
>> <asp:TemplateColumn HeaderText="Approved">
>> <ItemTemplate>
>> <%# FormatYesOrNo(DataBinder.Eval(Container.DataItem, "MyBitColumn")) %>
>> </ItemTemplate>
>> </asp:TemplateColumn>
>>
>> In the code behind:
>> public string FormatYesOrNo(bool x)
>> {
>> string z = "Yes";
>> if (x != true)
>> z = "No";
>> return z;
>> }
>>
>> I tried casting the late bound info the aspx to a bool (e.g.
>> (bool)DataBinder.Eval...), but that didn't work. I tried changing the
>> FormatYesOrNo(bool x) in the code behind to FormatYesOrNo(string x) and
>> changing the guts accordingly, but that didn't work.
>>
>> Any help appreciated.
>>
>> -TJ
>>
>>
>>
>>
>>
>
TJ Guest
-
TJ #4
Re: Databinder.Eval passed as argument is choking
Nevermind...got it:
((bool)DataBinder.Eval(Container.DataItem, "AJGApproved")) ? "Yes" : "No"
Just had to add the final casting touch. : )
Thank you so much!
"Elton Wang" <elton_wang@hotmail.com> wrote in message
news:%23gLpaQbzFHA.3892@TK2MSFTNGP12.phx.gbl...> Try following:
>
> <asp:TemplateColumn HeaderText="Approved">
> <ItemTemplate>
> <%# (DataBinder.Eval(Container.DataItem, "MyBitColumn")) ? "Yes" : "No" %>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> HTH
>
> "TJ" <teejay@newsgroups.nospam> wrote in message
> news:%23Mtyo7azFHA.3408@TK2MSFTNGP09.phx.gbl...>>>I have a datagrid that has a boolean column. The sql data is a bit stored
>>as a 1 or 0. Doing a straight up DataBinder.Eval(Container.DataItem,
>>"MyColumn") displays a "True" or "False" in the grid. No problems here.
>>
>> What I want is for it to display a "Yes" or "No". So I'm using a
>> TemplateColumn instead of a BoundColumn so I can pass the value into a
>> function and return a string that says Yes or No. My problem is that the
>> function won't take the value seemingly no matter how I cast or don't
>> cast the argument when I send or in the receiving mechanism of the
>> function.
>>
>> In the aspx page:
>>
>> <asp:TemplateColumn HeaderText="Approved">
>> <ItemTemplate>
>> <%# FormatYesOrNo(DataBinder.Eval(Container.DataItem, "MyBitColumn")) %>
>> </ItemTemplate>
>> </asp:TemplateColumn>
>>
>> In the code behind:
>> public string FormatYesOrNo(bool x)
>> {
>> string z = "Yes";
>> if (x != true)
>> z = "No";
>> return z;
>> }
>>
>> I tried casting the late bound info the aspx to a bool (e.g.
>> (bool)DataBinder.Eval...), but that didn't work. I tried changing the
>> FormatYesOrNo(bool x) in the code behind to FormatYesOrNo(string x) and
>> changing the guts accordingly, but that didn't work.
>>
>> Any help appreciated.
>>
>> -TJ
>>
>>
>>
>>
>>
>
TJ Guest



Reply With Quote

