Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > DataGrid

Reply
Thread Tools

DataGrid

 
 
Raja Balaji R
Guest
Posts: n/a
 
      10-21-2003
hi

i have table emp which contains field eno, ename, esal.

i displaying it in a datagrid

eno column is hyperlinkcolumn
ename, esal are normal bound column

i want that eno hyperlinkcolumn href value to be in
form "sample.aspx?eno=1&ename=rock", 1 is the value of
eno column(hyper column) value and rock is the ename column
(bound column).

how to give URL, URL field, URL format string values in
datagrid columns property dialog.

thanks in advance

 
Reply With Quote
 
 
 
 
Mike Moore [MSFT]
Guest
Posts: n/a
 
      10-21-2003
Hi Raja,

You need to use the ItemDataBound event.

I created a query using the Pubs database as follows:
"SELECT au_id, au_lname, au_fname FROM authors"

I then added a datagrid with a hyperlink column plus autogenerate columns.

I then use string manipulation to create the hyperlink as follows.

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then

CType(e.Item.Cells(0).Controls(0), HyperLink).NavigateUrl =
"http://" & e.Item.DataItem("au_id") & "?lname=" &
e.Item.DataItem("au_lname") & "&fname=" & e.Item.DataItem("au_fname")

CType(e.Item.Cells(0).Controls(0), HyperLink).Text = "http://"
& e.Item.DataItem("au_id") & "?lname=" & e.Item.DataItem("au_lname") &
"&fname=" & e.Item.DataItem("au_fname")

End If

End Sub

----
I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computerís security.

This posting is provided "AS IS", with no warranties, and confers no rights.


--------------------
> Content-Class: urn:content-classes:message
> From: "Raja Balaji R" <(E-Mail Removed)>
> Sender: "Raja Balaji R" <(E-Mail Removed)>
> Subject: DataGrid
> Date: Tue, 21 Oct 2003 02:07:24 -0700
> Lines: 19
> Message-ID: <0acc01c397b2$bdeb6780$(E-Mail Removed)>
> MIME-Version: 1.0
> Content-Type: text/plain;
> charset="iso-8859-1"
> Content-Transfer-Encoding: 7bit
> X-Newsreader: Microsoft CDO for Windows 2000
> Thread-Index: AcOXsr3oKdd8sO/MTBmykWz0QVZOfw==
> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
> Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> Path: cpmsftngxa06.phx.gbl
> Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.framework.aspnet.webcontro ls:15524
> NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>
> hi
>
> i have table emp which contains field eno, ename, esal.
>
> i displaying it in a datagrid
>
> eno column is hyperlinkcolumn
> ename, esal are normal bound column
>
> i want that eno hyperlinkcolumn href value to be in
> form "sample.aspx?eno=1&ename=rock", 1 is the value of
> eno column(hyper column) value and rock is the ename column
> (bound column).
>
> how to give URL, URL field, URL format string values in
> datagrid columns property dialog.
>
> thanks in advance
>
>


 
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
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams ASP .Net 0 03-02-2004 08:35 PM
RE: Datagrid: how cut short display of a long description in a datagrid column =?Utf-8?B?U3VyZXNo?= ASP .Net 0 03-02-2004 08:31 PM
datagrid in datagrid BK Kim ASP .Net 1 03-02-2004 06:34 AM
Call Datagrid Command column outside datagrid Dave ASP .Net 0 11-20-2003 11:11 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments