473,326 Members | 2,095 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,326 software developers and data experts.

get value by index and not column name...

When using a repeater control I want to get the database value by index
instead of using the column name. How can I do this? My current repeater code
looks like this:

<asp:repeater id="rprtroplinks" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<A href="<%# DataBinder.Eval(Container.DataItem,
"Specimen_Link")%>">Link</A>
<br>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:repeater>

Nov 19 '05 #1
1 8087
Mike:
I don't think you can do it via the DataBinder.Eval function, but you can do
it by casting Container.DataItem to the appropriate type. If you are
binding to a Dataset, DataView or DataTable then it'll be a DataRowView. If
you are binding to an DataReader then it'll be a DbDataRecord

You can learn more about this explicit casting at
http://support.microsoft.com/default...b;en-us;307860

Once you have that, you can do:

<%# ctype(Container.DataItem, DataRowView)(0) %>
or in C#
<%# ((DataRowView)Container.DataItem)[0] %>

switch DataRowView to DbDataRecord if you are binding to a DataReader.

Also, don't forget to add <%@ Import Namespace="System.Data" %> for
DataRowView and <%@ Import Namespace="System.Data.Common" %> for
DbDataRecord...

Hope this helps,
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
When using a repeater control I want to get the database value by index
instead of using the column name. How can I do this? My current repeater
code
looks like this:

<asp:repeater id="rprtroplinks" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<A href="<%# DataBinder.Eval(Container.DataItem,
"Specimen_Link")%>">Link</A>
<br>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:repeater>

Nov 19 '05 #2

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

Similar topics

20
by: | last post by:
If I need to check if a certain value does exist in a field, and return either "yes" or "not" which query would be the most effestive?
2
by: vasanth kumar | last post by:
Hi, I have a problem in dealing with the return value of the SQL command. I know how to do, when SQL command returns Recordsets. But in my case it returns a single value. The following code fails...
3
by: Wilson Wu | last post by:
Hi, How can I find the field value in the dataset and then assign one of the field value to a variable ? Thanks Wilson
4
by: kscdavefl | last post by:
I ahve a datagrid on a web form. I need to change the value in column 3 as follows. If the value in column 3 reads 0, I want to change it to read YES. How can I accomplish this task. ...
5
by: Catalin Porancea | last post by:
Whenever I try this: ____________________________________________________________________ Dim cmd_sp_payments As SqlCommand = New SqlCommand("sp_payments", con) cmd_sp_payments.CommandType =...
0
by: Benny Raymond | last post by:
reply to: benny@pocketrocks.com if possible: I'm trying to set up a hierarchy system in this database where each row can be related to a previous row. The problem is that when I go to...
0
by: JSantora | last post by:
Essentially, InsertAT is broken! For the past couple of hours, I've been getting this "Parameter name: '-2147483550' is not a valid value for 'index'." error. Apparently, its caused by having...
12
by: Prabu Subroto | last post by:
Dear my friends... I am using postgres 7.4 and SuSE 9.1. I want to use auto_increment as on MySQL. I look up the documentation on www.postgres.com and I found "serial" . But I don't know...
33
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range...
5
by: montybytes | last post by:
Hi there, Although, I have already placed this question in the HTML/CSS section, perhaps it might be worthwhile asking the question here as well. I have a JavaScript function which retrieves...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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...
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)...
1
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...
0
isladogs
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...

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.