Hi, all:
I need a help from you about DataGrid control.
I created a DataGrid, dg, in design view of .NET visual Stadio and use the
builder to add a Hyperlink column to dg.
I want to try to assign a column of URLs to this hyperlink column in
programming way (ie., dynamically assignment). However, I can not find a way
to continue doing it.
Do you have ideas about it? Thanks.
David 10 1882
On Fri, 14 Oct 2005 08:53:14 -0700, david wrote: Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it.
Do you have ideas about it? Thanks.
David
Let's assume that you have the list in the dataset, dataview, array. You
can use DataBinding to provide your grid with values. For a good article: http://www.codeproject.com/aspnet/Ma...ataBinding.asp
HI David,
In DataGrid_ItemDataBound event:
HyperLink link = (HyperLink)e.Item.Cells[link_Column_index].Controls[0];
link.NavigateUrl = getURL();
HTH
Elton Wang
"david" wrote: Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it.
Do you have ideas about it? Thanks.
David
Thank you.
It is not completely clear to me. For example, I have a list of URLs, called
URLs which is a column of a dataset, and I have a column of hyperlink column,
link, in the datagrid, dg. Assume that these two columns have the same size.
In the design view, I have left the URL box empty for the hyperlink column in
the property builder.
Now in the code behide, I try to fill in the URL box (property item) for
each hyperlink column item after I got the list of URLs. Can I do the
following:
dg.Columns("link") = URLs
Does it make sense?
David
"Elton W" wrote: HI David,
In DataGrid_ItemDataBound event:
HyperLink link = (HyperLink)e.Item.Cells[link_Column_index].Controls[0]; link.NavigateUrl = getURL();
HTH
Elton Wang "david" wrote:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it.
Do you have ideas about it? Thanks.
David
You need bind datagrid with data source:
dg.DataSource = dataSourceObject
dg.DataBind()
And specify link column's binding field:
Dim linkCol As HyperLinkColumn = CType(dg.Columns(link_index),
HyperLinkColumn )
linkCol.DataTextField = "URL_FIELD_NAME"
Or in DataGrid_ItemDataBound event:
using DataRowView object (e.Item.DataItem)
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
HyperLink link = CType(e.Item.Cells(link_Column_index).Controls(0), HyperLink)
link.NavigateUrl = drv("URL_FIELD_NAME").ToString
HTH
"david" wrote: Thank you.
It is not completely clear to me. For example, I have a list of URLs, called URLs which is a column of a dataset, and I have a column of hyperlink column, link, in the datagrid, dg. Assume that these two columns have the same size. In the design view, I have left the URL box empty for the hyperlink column in the property builder.
Now in the code behide, I try to fill in the URL box (property item) for each hyperlink column item after I got the list of URLs. Can I do the following:
dg.Columns("link") = URLs
Does it make sense?
David
"Elton W" wrote:
HI David,
In DataGrid_ItemDataBound event:
HyperLink link = (HyperLink)e.Item.Cells[link_Column_index].Controls[0]; link.NavigateUrl = getURL();
HTH
Elton Wang "david" wrote:
Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it.
Do you have ideas about it? Thanks.
David
thanks
I will try it.
David
"Elton W" wrote: You need bind datagrid with data source:
dg.DataSource = dataSourceObject dg.DataBind()
And specify link column's binding field:
Dim linkCol As HyperLinkColumn = CType(dg.Columns(link_index), HyperLinkColumn ) linkCol.DataTextField = "URL_FIELD_NAME"
Or in DataGrid_ItemDataBound event:
using DataRowView object (e.Item.DataItem)
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView) HyperLink link = CType(e.Item.Cells(link_Column_index).Controls(0), HyperLink) link.NavigateUrl = drv("URL_FIELD_NAME").ToString
HTH "david" wrote:
Thank you.
It is not completely clear to me. For example, I have a list of URLs, called URLs which is a column of a dataset, and I have a column of hyperlink column, link, in the datagrid, dg. Assume that these two columns have the same size. In the design view, I have left the URL box empty for the hyperlink column in the property builder.
Now in the code behide, I try to fill in the URL box (property item) for each hyperlink column item after I got the list of URLs. Can I do the following:
dg.Columns("link") = URLs
Does it make sense?
David
"Elton W" wrote:
HI David,
In DataGrid_ItemDataBound event:
HyperLink link = (HyperLink)e.Item.Cells[link_Column_index].Controls[0]; link.NavigateUrl = getURL();
HTH
Elton Wang "david" wrote:
> Hi, all: > I need a help from you about DataGrid control. > I created a DataGrid, dg, in design view of .NET visual Stadio and use the > builder to add a Hyperlink column to dg. > I want to try to assign a column of URLs to this hyperlink column in > programming way (ie., dynamically assignment). However, I can not find a way > to continue doing it. > > Do you have ideas about it? Thanks. > > David
You can also look at following URL: http://msdn.microsoft.com/library/de...tringtopic.asp
HTH
"david" wrote: thanks
I will try it.
David
"Elton W" wrote:
You need bind datagrid with data source:
dg.DataSource = dataSourceObject dg.DataBind()
And specify link column's binding field:
Dim linkCol As HyperLinkColumn = CType(dg.Columns(link_index), HyperLinkColumn ) linkCol.DataTextField = "URL_FIELD_NAME"
Or in DataGrid_ItemDataBound event:
using DataRowView object (e.Item.DataItem)
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView) HyperLink link = CType(e.Item.Cells(link_Column_index).Controls(0), HyperLink) link.NavigateUrl = drv("URL_FIELD_NAME").ToString
HTH "david" wrote:
Thank you.
It is not completely clear to me. For example, I have a list of URLs, called URLs which is a column of a dataset, and I have a column of hyperlink column, link, in the datagrid, dg. Assume that these two columns have the same size. In the design view, I have left the URL box empty for the hyperlink column in the property builder.
Now in the code behide, I try to fill in the URL box (property item) for each hyperlink column item after I got the list of URLs. Can I do the following:
dg.Columns("link") = URLs
Does it make sense?
David
"Elton W" wrote:
> HI David, > > In DataGrid_ItemDataBound event: > > HyperLink link = (HyperLink)e.Item.Cells[link_Column_index].Controls[0]; > link.NavigateUrl = getURL(); > > HTH > > Elton Wang > > > > "david" wrote: > > > Hi, all: > > I need a help from you about DataGrid control. > > I created a DataGrid, dg, in design view of .NET visual Stadio and use the > > builder to add a Hyperlink column to dg. > > I want to try to assign a column of URLs to this hyperlink column in > > programming way (ie., dynamically assignment). However, I can not find a way > > to continue doing it. > > > > Do you have ideas about it? Thanks. > > > > David
By the way, what does it mean by 0 in
HyperLink link = CType(e.Item.Cells(link_Column_index).Controls(0),
HyperLink) ?
Why use 0 in Control(0)? Can you explain this line of code?
Thanks
David
"Elton W" wrote: You can also look at following URL:
http://msdn.microsoft.com/library/de...tringtopic.asp
HTH
"david" wrote:
thanks
I will try it.
David
"Elton W" wrote:
You need bind datagrid with data source:
dg.DataSource = dataSourceObject dg.DataBind()
And specify link column's binding field:
Dim linkCol As HyperLinkColumn = CType(dg.Columns(link_index), HyperLinkColumn ) linkCol.DataTextField = "URL_FIELD_NAME"
Or in DataGrid_ItemDataBound event:
using DataRowView object (e.Item.DataItem)
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView) HyperLink link = CType(e.Item.Cells(link_Column_index).Controls(0), HyperLink) link.NavigateUrl = drv("URL_FIELD_NAME").ToString
HTH "david" wrote:
> Thank you. > > It is not completely clear to me. For example, I have a list of URLs, called > URLs which is a column of a dataset, and I have a column of hyperlink column, > link, in the datagrid, dg. Assume that these two columns have the same size. > In the design view, I have left the URL box empty for the hyperlink column in > the property builder. > > Now in the code behide, I try to fill in the URL box (property item) for > each hyperlink column item after I got the list of URLs. Can I do the > following: > > dg.Columns("link") = URLs > > Does it make sense? > > David > > > "Elton W" wrote: > > > HI David, > > > > In DataGrid_ItemDataBound event: > > > > HyperLink link = (HyperLink)e.Item.Cells[link_Column_index].Controls[0]; > > link.NavigateUrl = getURL(); > > > > HTH > > > > Elton Wang > > > > > > > > "david" wrote: > > > > > Hi, all: > > > I need a help from you about DataGrid control. > > > I created a DataGrid, dg, in design view of .NET visual Stadio and use the > > > builder to add a Hyperlink column to dg. > > > I want to try to assign a column of URLs to this hyperlink column in > > > programming way (ie., dynamically assignment). However, I can not find a way > > > to continue doing it. > > > > > > Do you have ideas about it? Thanks. > > > > > > David
In a cell, there are one or more control(s), e.g. you can put a label and a
textbox or even just a white space (treated as Literal control).
Hence, cell.Controls(0) means first control, in your case Hyperlink control.
"david" wrote: Hi, all: I need a help from you about DataGrid control. I created a DataGrid, dg, in design view of .NET visual Stadio and use the builder to add a Hyperlink column to dg. I want to try to assign a column of URLs to this hyperlink column in programming way (ie., dynamically assignment). However, I can not find a way to continue doing it.
Do you have ideas about it? Thanks.
David
Hi, Elton:
in your sample code,
Dim linkCol As HyperLinkColumn = CType(dg.Columns(link_index),
HyperLinkColumn )
The link_index means the column index such as 0, 1, and so on, is that right?
Thanks
David
"Elton W" wrote: You need bind datagrid with data source:
dg.DataSource = dataSourceObject dg.DataBind()
And specify link column's binding field:
Dim linkCol As HyperLinkColumn = CType(dg.Columns(link_index), HyperLinkColumn ) linkCol.DataTextField = "URL_FIELD_NAME"
Or in DataGrid_ItemDataBound event:
using DataRowView object (e.Item.DataItem)
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView) HyperLink link = CType(e.Item.Cells(link_Column_index).Controls(0), HyperLink) link.NavigateUrl = drv("URL_FIELD_NAME").ToString
HTH "david" wrote:
Thank you.
It is not completely clear to me. For example, I have a list of URLs, called URLs which is a column of a dataset, and I have a column of hyperlink column, link, in the datagrid, dg. Assume that these two columns have the same size. In the design view, I have left the URL box empty for the hyperlink column in the property builder.
Now in the code behide, I try to fill in the URL box (property item) for each hyperlink column item after I got the list of URLs. Can I do the following:
dg.Columns("link") = URLs
Does it make sense?
David
"Elton W" wrote:
HI David,
In DataGrid_ItemDataBound event:
HyperLink link = (HyperLink)e.Item.Cells[link_Column_index].Controls[0]; link.NavigateUrl = getURL();
HTH
Elton Wang "david" wrote:
> Hi, all: > I need a help from you about DataGrid control. > I created a DataGrid, dg, in design view of .NET visual Stadio and use the > builder to add a Hyperlink column to dg. > I want to try to assign a column of URLs to this hyperlink column in > programming way (ie., dynamically assignment). However, I can not find a way > to continue doing it. > > Do you have ideas about it? Thanks. > > David
Yes
"david" wrote: Hi, Elton:
in your sample code, Dim linkCol As HyperLinkColumn = CType(dg.Columns(link_index), HyperLinkColumn )
The link_index means the column index such as 0, 1, and so on, is that right?
Thanks
David "Elton W" wrote:
You need bind datagrid with data source:
dg.DataSource = dataSourceObject dg.DataBind()
And specify link column's binding field:
Dim linkCol As HyperLinkColumn = CType(dg.Columns(link_index), HyperLinkColumn ) linkCol.DataTextField = "URL_FIELD_NAME"
Or in DataGrid_ItemDataBound event:
using DataRowView object (e.Item.DataItem)
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView) HyperLink link = CType(e.Item.Cells(link_Column_index).Controls(0), HyperLink) link.NavigateUrl = drv("URL_FIELD_NAME").ToString
HTH "david" wrote:
Thank you.
It is not completely clear to me. For example, I have a list of URLs, called URLs which is a column of a dataset, and I have a column of hyperlink column, link, in the datagrid, dg. Assume that these two columns have the same size. In the design view, I have left the URL box empty for the hyperlink column in the property builder.
Now in the code behide, I try to fill in the URL box (property item) for each hyperlink column item after I got the list of URLs. Can I do the following:
dg.Columns("link") = URLs
Does it make sense?
David
"Elton W" wrote:
> HI David, > > In DataGrid_ItemDataBound event: > > HyperLink link = (HyperLink)e.Item.Cells[link_Column_index].Controls[0]; > link.NavigateUrl = getURL(); > > HTH > > Elton Wang > > > > "david" wrote: > > > Hi, all: > > I need a help from you about DataGrid control. > > I created a DataGrid, dg, in design view of .NET visual Stadio and use the > > builder to add a Hyperlink column to dg. > > I want to try to assign a column of URLs to this hyperlink column in > > programming way (ie., dynamically assignment). However, I can not find a way > > to continue doing it. > > > > Do you have ideas about it? Thanks. > > > > David This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ravikanth[MVP] |
last post by:
Hi
asp:DataGrid id="YourID" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="Sample Column">
<ItemTemplate>
<asp:Hyperlink runat="server" Text='<%...
|
by: damonf |
last post by:
I'm currently trying to add an ASP hyperlink to a
template column in a datagrid. The normal hyperlink
column doesn't give me the ability to add attributes to
the item. In my grid there are four...
|
by: YSRao |
last post by:
Dear Friends
I would like to know how to assign some parameter and values to the url in a datagrid hyperlink column..
i have datagrid with 5 items and i made the column as hyperlinkcolumn and here...
|
by: Paul |
last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like
00001,000002, ect. Just wondering how to get the text value of the cell as
tempstring =...
|
by: D. Shane Fowlkes |
last post by:
Hello All.
I keep asking for help with this on the www.asp.net forums and nobody seems
to be able to help. What I'm trying to accomplish is very simple. I simply
want to create a Hyperlink...
|
by: epigram |
last post by:
I'm using the DataGrid with AutoGenerateColumns set to false and choosing
which columns I want in the grid by using the <Columns> attribute. What I
want to do is to create a hyperlink out of one...
|
by: Tim::.. |
last post by:
I currently have the following datagrid but want to turn the name and email
column into a hyperlink in the codebehind!
Can someone please tell me how I achieve this!
Thanks
Private Sub...
|
by: Mike Fellows |
last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid
i basically have a datagrid that im populating from a dataset
Me.DataGrid1.DataSource = ds.Tables(0)
the datagrid then has 5...
|
by: TPhelps |
last post by:
I have a sample of an unbound (autogeneratecolumns is true) sortable/pagable
datagrid that works.
I want to change one of the columns to a hyperlink. The examples I find use
a bound column. I...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |