Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to assign a column of URLs to Hyperlink Column of a DataGrid c

Reply
Thread Tools

How to assign a column of URLs to Hyperlink Column of a DataGrid c

 
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      10-14-2005
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
 
Reply With Quote
 
 
 
 
intrader
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      10-14-2005
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

 
Reply With Quote
 
=?Utf-8?B?ZGF2aWQ=?=
Guest
Posts: n/a
 
      10-17-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink davetichenor ASP .Net 1 10-30-2006 02:57 PM
How to add a hyperlink column to asp.net datagrid - where only one value is a hyperlink Dave ASP .Net Datagrid Control 0 10-21-2006 07:48 PM
HyperLink Column and Button Column in a DataGrid =?Utf-8?B?V2FyYW4=?= ASP .Net 0 08-09-2005 12:00 AM
How to Assign Paramer & Values to a hyperlink column in a datagrid =?Utf-8?B?WVNSYW8=?= ASP .Net 1 05-31-2004 10:02 AM
Distinguish text URLs from non-text URLs? Kaidi Java 5 01-04-2004 10:15 AM



Advertisments