Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2004, 02:19 PM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default Setting DataNavigateURLFormatString in datagrid

Hi I have a datagrid that has only one column which is a hyperlinkcolumn. I load the data from my sql table and it shows all the records fine. I am using datareader to read each record. The hyperlinks are link to files stored on the server. I need to set the DataNavigateURLFormatString for each hyperlink, so that it points to the right file. After reading all the records I am showing them in a datagrid. The problem is that all my links point to the last record read. I am mixing datareader and sqldataadapter. Here is my code in code behind file.
-------------------------------------------------
Private Sub GetFiles(ByVal strName)

Dim strConn As String
'Get connection string from Web.Config
strConn = ConfigurationSettings.AppSettings("ConnectionStrin g")

Dim DName As String = strName

Dim MySQL As String = "Select DDocName from tbl_DocFile where DName=@DName"
Dim cmd As New SqlCommand(MySQL, New SqlConnection(strConn))
cmd.Parameters.Add(New SqlParameter("@DName", DName))

Dim objDR As SqlDataReader
cmd.Connection.Open()
Try

objDR = cmd.ExecuteReader(System.Data.CommandBehavior.Clos eConnection)
While objDR.Read()
sDocName = objDR("DDocName")
If sDocName <> "" Then
Dim strpath As String = "\ordinance\pdffiles\"
Dim hl As HyperLinkColumn
hl = Me.DataGrid1.Columns(0)
hl.DataNavigateUrlFormatString = strpath & sDocName
End If
End While
If sDocName = "" Then
cmd.Connection.Close()
End If
Catch ex As Exception
Dim str As String = ex.ToString
cmd.Connection.Close()
End Try

Me.SqlDataAdapter2.Fill(Me.DataSet11)
Me.DataGrid1.DataBind()

End Sub
--------------------------------------------------------

I want sDocName to be changing for each hyperlink in the datagrid. HTML portion looks like this:-


<aspataGrid id=DataGrid1 style="Z-INDEX: 198; LEFT: 80px; POSITION: absolute; TOP: 920px" runat="server" Width="400px" Height="58px" DataMember="tbl_DocFile" AutoGenerateColumns="False" DataSource="<%# DataSet11 %>" PageSize="4" AllowPaging="True" ShowHeader="False">
<AlternatingItemStyle Font-Size="XX-Small" Font-Names="Arial"></AlternatingItemStyle>
<ItemStyle Font-Size="XX-Small" Font-Names="Arial"></ItemStyle>
<HeaderStyle Font-Size="XX-Small" Font-Names="Arial"></HeaderStyle>
<FooterStyle Font-Size="XX-Small" Font-Names="Arial"></FooterStyle>
<Columns>
<asp:HyperLinkColumn Text="DDocName" Target="_blank" DataNavigateUrlField="DDocName" DataTextField="DDocName"></asp:HyperLinkColumn>
</Columns>
</aspataGrid>

 
Old December 9th, 2004, 01:32 AM
Authorized User
 
Join Date: Aug 2004
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Default

NEver Mind, I got it working.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid / DateTime Format Setting tanakrita ASP.NET 1.0 and 1.1 Basics 2 May 17th, 2007 09:56 PM
DataNavigateUrlFormatString mparr_1972 Classic ASP Basics 3 July 18th, 2006 10:44 AM
DataNavigateUrlFormatString lroyce ASP.NET 1.0 and 1.1 Basics 3 June 8th, 2006 05:47 PM
Setting Column width in Datagrid anita General .NET 2 April 13th, 2005 02:25 AM
Setting the border properties in datagrid. katsarosj ASP.NET 1.0 and 1.1 Basics 2 November 11th, 2003 01:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.