I have an SQLDataSource control, which is bound to an ASP.net 2.0
GridView control. It outputs a list of documents that a user can check
in or check out of the database.
In my gridview, I have a column called "checked out" which is bound to
a column in my database, called "checkedout". A zero means no, and a
one means yes (that the document is checked out).
Showing a 0 or 1 is ugly and I want to use No or Yes. I can't figure
out how to get at my SQLDataSource control's rows so that I can look at
them and write text out, rather than what's in the database (a 0 or 1).
My code is like this:
<asp:Label ID="CheckedOut" runat="server" text='<%# Eval("CheckedOut")
%>' />
I've tried assiging the return value of Eval("CheckedOut") to a local
variable, but I get asp errors telling me that Eval must be used in a
databound control.
I want to do something like this:
If Eval("CheckedOut") = "0" Then
...
Else
...
End Of
I can post real code if that helps- but it's more the approach I am
looking for...
Thanks for any help
idletask. 3 13676
You could write a custom function and bind to that instead.
<asp:Label ID="CheckedOut" runat="server"
text='<%# GetCheckedOutValue((int)DataBinder.Eval(Container. DataItem,
"CheckedOut")) %> />
Then in code behind or inline:
protected string GetCheckedOutValue(int checkedOut)
{
if(checkedOut == 0)
return "True";
else
return "False";
}
"id******@msn.com" wrote: I have an SQLDataSource control, which is bound to an ASP.net 2.0 GridView control. It outputs a list of documents that a user can check in or check out of the database.
In my gridview, I have a column called "checked out" which is bound to a column in my database, called "checkedout". A zero means no, and a one means yes (that the document is checked out).
Showing a 0 or 1 is ugly and I want to use No or Yes. I can't figure out how to get at my SQLDataSource control's rows so that I can look at them and write text out, rather than what's in the database (a 0 or 1).
My code is like this:
<asp:Label ID="CheckedOut" runat="server" text='<%# Eval("CheckedOut") %>' />
I've tried assiging the return value of Eval("CheckedOut") to a local variable, but I get asp errors telling me that Eval must be used in a databound control.
I want to do something like this:
If Eval("CheckedOut") = "0" Then ... Else ... End Of
I can post real code if that helps- but it's more the approach I am looking for...
Thanks for any help
idletask.
The wrapper function is my suggestion also.
That's kinda what "presentation" layer means.
You "present" the data the way you want to.
Keep in mind, that if you want to edit, you need to use a checkbox.
Or write a custom user control...which maybe has a drop down list of
--Select--
True
False
.....
<id******@msn.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... I have an SQLDataSource control, which is bound to an ASP.net 2.0 GridView control. It outputs a list of documents that a user can check in or check out of the database.
In my gridview, I have a column called "checked out" which is bound to a column in my database, called "checkedout". A zero means no, and a one means yes (that the document is checked out).
Showing a 0 or 1 is ugly and I want to use No or Yes. I can't figure out how to get at my SQLDataSource control's rows so that I can look at them and write text out, rather than what's in the database (a 0 or 1).
My code is like this:
<asp:Label ID="CheckedOut" runat="server" text='<%# Eval("CheckedOut") %>' />
I've tried assiging the return value of Eval("CheckedOut") to a local variable, but I get asp errors telling me that Eval must be used in a databound control.
I want to do something like this:
If Eval("CheckedOut") = "0" Then ... Else ... End Of
I can post real code if that helps- but it's more the approach I am looking for...
Thanks for any help
idletask.
Another option would be in the DB itself, send another column which has
the value of true/false, based on the value of this column which is 0/1
sloan wrote: The wrapper function is my suggestion also.
That's kinda what "presentation" layer means.
You "present" the data the way you want to.
Keep in mind, that if you want to edit, you need to use a checkbox. Or write a custom user control...which maybe has a drop down list of --Select-- True False
.... <id******@msn.com> wrote in message news:11**********************@g49g2000cwa.googlegr oups.com...I have an SQLDataSource control, which is bound to an ASP.net 2.0 GridView control. It outputs a list of documents that a user can check in or check out of the database.
In my gridview, I have a column called "checked out" which is bound to a column in my database, called "checkedout". A zero means no, and a one means yes (that the document is checked out).
Showing a 0 or 1 is ugly and I want to use No or Yes. I can't figure out how to get at my SQLDataSource control's rows so that I can look at them and write text out, rather than what's in the database (a 0 or 1).
My code is like this:
<asp:Label ID="CheckedOut" runat="server" text='<%# Eval("CheckedOut") %>' />
I've tried assiging the return value of Eval("CheckedOut") to a local variable, but I get asp errors telling me that Eval must be used in a databound control.
I want to do something like this:
If Eval("CheckedOut") = "0" Then ... Else ... End Of
I can post real code if that helps- but it's more the approach I am looking for...
Thanks for any help
idletask. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: euan |
last post by:
HI Guys,
I have bee using conditional formatting in the datagrid recently and I
am moving over to framework 2.0 and noticed the datagrid has been
replaced by the gridview. So, I would like to do...
|
by: Jon S via DotNetMonster.com |
last post by:
HI all,
I'm returning a dataset to a gridview control. When the gridview asp.net
control is populated from the returning dataset some of the cells remain
empty. This is expected as some data...
|
by: Mike P |
last post by:
Where exactly are the updateparameters of a gridview picked up from? I
have created 2 very similar gridviews and given the updateparameters the
same names as in my edititemtemplates. Yet this...
|
by: Dabbler |
last post by:
I'm trying to replace a user code in data column with user friendly text for
a GridView ItemTemplate as in:
Text='<%# Eval("LocationType")%> == "P" ? "Pickup" : "DropOff"'
However the value...
|
by: Mike P |
last post by:
I am trying to edit a gridview while using paging, but whenever I try to
edit a row on a page other than page 1, I get an error. Here is my
gridview and my code :
<asp:GridView ID="GridView1"...
|
by: DC |
last post by:
The problem
I'm using the .NET GridView and FormView objects for the first time and
im getting the error "An OleDbParameter with ParameterName '@ID' is not
contained by this...
|
by: cyningeston |
last post by:
OS: WinXP Pro, VB/ASP/ADO.NET
I'm building a web-based supplier management application. For each supplier we are required by the FDA to track certain documents. I've managed to pull them from...
|
by: tim.cavins |
last post by:
I have a GridView populated by an ObjectDataSource.
I am having issues passing the parameters to the objectdatasource. I
have verified that the method is being called but none of the
parameters...
|
by: DC |
last post by:
Hi,
I am using a GridView to present data in a DataTable, which I store
only in ViewState and when the user hits the "OK" button the rows in
the DataTable will be used to execute transactions.
...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |