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

Help on DataBinding ??

Dear all,

I have a datagrid which is populated with a dataset as follow:

myDataGrid.DataSource = ds.Tables(0)
myDataGrid.DataBind()

Then I need to create a Hyperlink column from my grid.Clicking on that lik
will pass the content of the click link to a page. For that I add the
following to my page :

<asp:HyperLinkColumn>
DataNavigateUrlField='<% "Event.aspx?ReelId=" & Container.DataItem("ID")
%>' </asp:HyperLinkColumn>

When running my application, I get an error message saying that the field ID
is not existing in the grid datasource.

Then I check the content of my dataset which is pass to the grid as
datasource by watching the content of ds.Tables(0).Columns(0) and the name
of that first column I am interresting in is "ID".

How do you explain that it cannot bind to the column in my dataset ?
What did I do wrong ??

Thnaks for your help

regards
serge

Nov 19 '05 #1
3 1016
Try
<asp:HyperLinkColumn Text="Hyperlink Text"
DataNavigateUrlField="SomeDataSourceField"
DataNavigateUrlFormatString="mysample.aspx?ID={0}"
Target="_blank" />

Hope that helps
Patrick

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:25**********************************@microsof t.com...
Dear all,

I have a datagrid which is populated with a dataset as follow:

myDataGrid.DataSource = ds.Tables(0)
myDataGrid.DataBind()

Then I need to create a Hyperlink column from my grid.Clicking on that lik
will pass the content of the click link to a page. For that I add the
following to my page :

<asp:HyperLinkColumn>
DataNavigateUrlField='<% "Event.aspx?ReelId=" & Container.DataItem("ID")
%>' </asp:HyperLinkColumn>

When running my application, I get an error message saying that the field ID is not existing in the grid datasource.

Then I check the content of my dataset which is pass to the grid as
datasource by watching the content of ds.Tables(0).Columns(0) and the name of that first column I am interresting in is "ID".

How do you explain that it cannot bind to the column in my dataset ?
What did I do wrong ??

Thnaks for your help

regards
serge

Nov 19 '05 #2
Hi patrick

Thanks for your answer.
I have test that and I am quite surprise that the principle works fine..

But things needs to be clarify:

First of all doing like this adds an extra column in my datagrid with the
same content and the column which is in my dataset bound to the grid.
In other words I have 2 similar columns.

Is it possible to do that based on my already bound columns instead of
adding a new one ?

The second point is to know if there is a possiblity to catch the click
event on the link before it is postback to the server. This in a similar way
has the "CommandName" tag of the ButtonColumn ?

And as the last question, any idea why the previous solution was not working ?
"Patrick.O.Ige" wrote:
Try
<asp:HyperLinkColumn Text="Hyperlink Text"
DataNavigateUrlField="SomeDataSourceField"
DataNavigateUrlFormatString="mysample.aspx?ID={0}"
Target="_blank" />

Hope that helps
Patrick

"serge calderara" <se************@discussions.microsoft.com> wrote in
message news:25**********************************@microsof t.com...
Dear all,

I have a datagrid which is populated with a dataset as follow:

myDataGrid.DataSource = ds.Tables(0)
myDataGrid.DataBind()

Then I need to create a Hyperlink column from my grid.Clicking on that lik
will pass the content of the click link to a page. For that I add the
following to my page :

<asp:HyperLinkColumn>
DataNavigateUrlField='<% "Event.aspx?ReelId=" & Container.DataItem("ID")
%>' </asp:HyperLinkColumn>

When running my application, I get an error message saying that the field

ID
is not existing in the grid datasource.

Then I check the content of my dataset which is pass to the grid as
datasource by watching the content of ds.Tables(0).Columns(0) and the

name
of that first column I am interresting in is "ID".

How do you explain that it cannot bind to the column in my dataset ?
What did I do wrong ??

Thnaks for your help

regards
serge


Nov 19 '05 #3
Yes Serge the ne you posted earlier wasn't working becos you weren't
giving the right values to the HyperlinkColumn
And yes you can keep adding if you need to have more HyperLinkColumns..

If you need more flexibility try using TemplateColumns and in there add
controls you need
Hope that helps
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Jan 30 '06 #4

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

Similar topics

4
by: CGuy | last post by:
Hi, I have an ASPX page which has a datagrid and this datagrid is bound to a Custom Collection. sample code this.DataGrid1.DataSource = UserManager.Users; this.DataGrid1.DataBind();
3
by: Lloyd Sheen | last post by:
I have several apps that use a roll your own approach, but I am embarking on a project which will not allow that with the time constraints. I have gened up a little app to try the databinding...
3
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
4
by: Ben | last post by:
Hi, I'm using images in my menu control. I have my menu setup based on this example: http://msdn2.microsoft.com/en-US/library/system.web.ui.webcontrols.menuitembinding.imageurlfield(VS.80).aspx ...
2
by: hwiechers | last post by:
I have two drop down lists on a page. Each one is hooked up to a separate SqlDataSource. The second data source has a ControlParameter set to the selected value of the first drop down. When I set...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
3
by: Ken Foskey | last post by:
I am a new VS and C# developer with 20 plus years programming experience and I am finding the database stuff incredibly frustrating. I have read programming c# 3.0 pretty much cover to cover, ...
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...
0
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.