473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

controlling databound ASP

Hi,

I'm more of a windows programmer than ASP and I've having a little
difficulty in ASP.Net (framework 2.0) - VB.net

I have a datagrid on an aspx page and the html is building the display in a
table row by row. A sample row being

<tr>
<td>Comment:</td>
<td><%# Databinder.Eval(Container.DataItem,"comment") %></td>
</tr>

I want to only write these rows where there is data. I think I need to mix
the asp <% and databound <%# elements in some way but maybe this is not going
to be possible ?

I tried to kick off by at least trying to blank out the label in the
following way (slightly desperate but I felt it might be a step in the right
direction!) but this doesn't work although I can't see why not

<%# DataBinder.Eval(Container.DataItem, "Comment").Equals("") & "":"Comment"
%>

VS is telling me a bracket is expected and thate there are 2 additional
unspecified syntax errors in this one line !

Thanks for any help on this!

Ben.
Aug 15 '07 #1
6 1389
You can do this.

create a dataset for your data
bind your datagrid like this

datagrid.datasource = ds;
datagrid.databind();

that will bind your datagrid.

if you want to only show certain data items then you can specify that by
going to the properties of the grid and add the columns you want to show.
"Ben." <Be*@discussions.microsoft.comwrote in message
news:61**********************************@microsof t.com...
Hi,

I'm more of a windows programmer than ASP and I've having a little
difficulty in ASP.Net (framework 2.0) - VB.net

I have a datagrid on an aspx page and the html is building the display in
a
table row by row. A sample row being

<tr>
<td>Comment:</td>
<td><%# Databinder.Eval(Container.DataItem,"comment") %></td>
</tr>

I want to only write these rows where there is data. I think I need to
mix
the asp <% and databound <%# elements in some way but maybe this is not
going
to be possible ?

I tried to kick off by at least trying to blank out the label in the
following way (slightly desperate but I felt it might be a step in the
right
direction!) but this doesn't work although I can't see why not

<%# DataBinder.Eval(Container.DataItem, "Comment").Equals("") &
"":"Comment"
%>

VS is telling me a bracket is expected and thate there are 2 additional
unspecified syntax errors in this one line !

Thanks for any help on this!

Ben.

Aug 15 '07 #2
Thanks for replying. I already have a page that is successfully showing the
results in the way you have outlined. The difficulty I have is not in
disregarding columns but not adding them for the specific records where they
are blank.

So if it were Name, Address, Phone. I would show these records where they
are filled out but only name and phone on the specific records where the
address is blank.

Cheers,

Ben.
Aug 15 '07 #3
if you have a grid, its only going to show the data you have. I have
something similiar. I have a grid on my page and it shows

name, office, phone number

and even though a name may be blank or office, etc, it still shows the rest
of the data for that row.
so I may have a grid look like this at times

name office phone number
Greg Philly 555-1212
Karen Orlando
Beth 555-1234

and i'm only using the dataset for my grid, I'm not doing anything specail
for this result.
Unless I'm missing what your saying, your grid should show like above
"Ben." <Be*@discussions.microsoft.comwrote in message
news:DD**********************************@microsof t.com...
Thanks for replying. I already have a page that is successfully showing
the
results in the way you have outlined. The difficulty I have is not in
disregarding columns but not adding them for the specific records where
they
are blank.

So if it were Name, Address, Phone. I would show these records where they
are filled out but only name and phone on the specific records where the
address is blank.

Cheers,

Ben.

Aug 15 '07 #4
The easiest way is to have your sql statement take care of it
Select * from (table) where (fieldname) is not null

David Wier
http://iWritePro.com
http://aspnet101.com

"Ben." <Be*@discussions.microsoft.comwrote in message
news:61**********************************@microsof t.com...
Hi,

I'm more of a windows programmer than ASP and I've having a little
difficulty in ASP.Net (framework 2.0) - VB.net

I have a datagrid on an aspx page and the html is building the display in
a
table row by row. A sample row being

<tr>
<td>Comment:</td>
<td><%# Databinder.Eval(Container.DataItem,"comment") %></td>
</tr>

I want to only write these rows where there is data. I think I need to
mix
the asp <% and databound <%# elements in some way but maybe this is not
going
to be possible ?

I tried to kick off by at least trying to blank out the label in the
following way (slightly desperate but I felt it might be a step in the
right
direction!) but this doesn't work although I can't see why not

<%# DataBinder.Eval(Container.DataItem, "Comment").Equals("") &
"":"Comment"
%>

VS is telling me a bracket is expected and thate there are 2 additional
unspecified syntax errors in this one line !

Thanks for any help on this!

Ben.

Aug 15 '07 #5
that would work but i think he still wants to show the row even if there is
no data for all the columns

at least from what I get from this, thats what he's trying to do.

"So if it were Name, Address, Phone. I would show these records where they
are filled out but only name and phone on the specific records where the
address is blank."
"David Wier" <da*******@davidwier.nospam.comwrote in message
news:Oo**************@TK2MSFTNGP03.phx.gbl...
The easiest way is to have your sql statement take care of it
Select * from (table) where (fieldname) is not null

David Wier
http://iWritePro.com
http://aspnet101.com

"Ben." <Be*@discussions.microsoft.comwrote in message
news:61**********************************@microsof t.com...
>Hi,

I'm more of a windows programmer than ASP and I've having a little
difficulty in ASP.Net (framework 2.0) - VB.net

I have a datagrid on an aspx page and the html is building the display in
a
table row by row. A sample row being

<tr>
<td>Comment:</td>
<td><%# Databinder.Eval(Container.DataItem,"comment") %></td>
</tr>

I want to only write these rows where there is data. I think I need to
mix
the asp <% and databound <%# elements in some way but maybe this is not
going
to be possible ?

I tried to kick off by at least trying to blank out the label in the
following way (slightly desperate but I felt it might be a step in the
right
direction!) but this doesn't work although I can't see why not

<%# DataBinder.Eval(Container.DataItem, "Comment").Equals("") &
"":"Comment"
%>

VS is telling me a bracket is expected and thate there are 2 additional
unspecified syntax errors in this one line !

Thanks for any help on this!

Ben.


Aug 15 '07 #6
I think I worded the question wrongly.

I can't use the SQL version because as Mike says I don't want to exclude the
row.

I don't have a problem showing the record when there is no data in one of
the fields.

Sorry this is my mistake but this is more of an ASP question than a datagrid
question.

The users can switch to a table view where there is one record per page in a
tabluar form build using the databinding but using template columns to show
the data in an asp table form. One row may be added like this in the asp for
example

<tr>
<td>Comment:</td>
<td><%# Databinder.Eval(Container.DataItem,"comment") %></td>
</tr>

what I would like to do is only add these individual rows where there is a
value in the field so in this case (although I would wrap all rows this way)
in pseudo code it would be

IF <%# Databinder.Eval(Container.DataItem,"comment") %= "" then
DO nothing / move to next row...
ELSE
<tr>
<td>Comment:</td>
<td><%# Databinder.Eval(Container.DataItem,"comment") %></td>
</tr>
END IF

Cheers,

Ben.

"Mike" wrote:
that would work but i think he still wants to show the row even if there is
no data for all the columns

at least from what I get from this, thats what he's trying to do.

"So if it were Name, Address, Phone. I would show these records where they
are filled out but only name and phone on the specific records where the
address is blank."
"David Wier" <da*******@davidwier.nospam.comwrote in message
news:Oo**************@TK2MSFTNGP03.phx.gbl...
The easiest way is to have your sql statement take care of it
Select * from (table) where (fieldname) is not null

David Wier
http://iWritePro.com
http://aspnet101.com

"Ben." <Be*@discussions.microsoft.comwrote in message
news:61**********************************@microsof t.com...
Hi,

I'm more of a windows programmer than ASP and I've having a little
difficulty in ASP.Net (framework 2.0) - VB.net

I have a datagrid on an aspx page and the html is building the display in
a
table row by row. A sample row being

<tr>
<td>Comment:</td>
<td><%# Databinder.Eval(Container.DataItem,"comment") %></td>
</tr>

I want to only write these rows where there is data. I think I need to
mix
the asp <% and databound <%# elements in some way but maybe this is not
going
to be possible ?

I tried to kick off by at least trying to blank out the label in the
following way (slightly desperate but I felt it might be a step in the
right
direction!) but this doesn't work although I can't see why not

<%# DataBinder.Eval(Container.DataItem, "Comment").Equals("") &
"":"Comment"
%>

VS is telling me a bracket is expected and thate there are 2 additional
unspecified syntax errors in this one line !

Thanks for any help on this!

Ben.


Aug 15 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Andrey Mosienko | last post by:
We are using PostgreSQL about two years beginning from version 7.0. I have one question about starting postmaster: Is there way to detach it from the controlling terminal under FreeBSD? My...
1
by: Patrick Demets | last post by:
I have a fairly simple form with databound text boxes, but changes (or new records) are not recognized. The text boxes are successfully populated with data (from the database) and I can cycle...
0
by: John Smith | last post by:
Hello all: Another day another problem :). How do you synch a databound combobox with the rest of the controls that are on a form. I have a combobox that lists a bunch of names and upon...
0
by: Ken Varn | last post by:
I have a strange problem with a databound listbox. It may be because of how I use it, but I am stumped by this behavior. Here is the scenario: I have a multiselect databound listbox that...
0
by: Coco | last post by:
Hi, who knows how to update the 'child' textboxes in a datarelated situation if the child records "doesn't yet exitsts/are still empty"? The problem can be explained with the Northwind database....
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
5
by: clickon | last post by:
This is driving me nuts, it is such a simply thing to do but i cannot for the life of me work out how you are suposed to do it. I want to update the data in DropDownListB based on what is...
1
by: Owen Blacker | last post by:
I've spent loads of time Googling to try to work this one out and I'm sure it's something obvious. I get an InvalidOperationException reading "Databinding methods such as Eval(), XPath(), and...
3
by: Jeff | last post by:
hey asp.net 2.0 I want to programmatically populate (with data from the database) a label control in a FormView on a webpage. Is it a good idea to put my logic inside the DataBound event of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
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...
0
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...
1
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)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.