Odd Problem - Datagrid

lorena

Centurion
Joined
Oct 23, 2003
Messages
134
Location
Phoenix, Arizona
I have two identical pages that list out the contents of two different folders with hyperlinks to each file. One works, the other doesn't. On the one that doesn't I get this error:
"Control 'dgFiles__ctl24__ctl1' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server"
There are 29 files in the folder with the page that doesn't work. If I set the page size to "20" I get the error above, if I set it to "15" I get the same error but the Control is 'dgFiles__ctl19__ctl1'. If I set the page size to "30" (one more than the number of files in the folder) - it works.
The other folder with the same type of page has hundreds of files in it and the paged datagrid works fine. I don't get it.
Here is all of my code:
Visual Basic:
<%@ Import Namespace = "System.Web" %>
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>Opportunities for Improvement - Closed</title>
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<script language="VB" runat="server">
			Sub Page_Load(sender as Object, e as EventArgs)
				If Not Page.IsPostBack then				
					BindData
				End If
			End Sub				
			
			Sub dgFiles_Paging(ByVal s As Object, ByVal e As DataGridPageChangedEventArgs)
				dgFiles.CurrentPageIndex = e.NewPageIndex
				BindData()
			End Sub
			
			Sub BindData()
				Dim dirInfo as New DirectoryInfo(Server.MapPath("/p1/Quality/Corr_Prev_Action_Cases/Opportunities for Improvement/Testing"))					
				Dim arrFileInfo  As Array
				Dim filesInfo   As FileInfo

				Dim filesTable   As New DataTable
				Dim drFiles    As DataRow
				Dim dvFiles   As DataView
				filesTable.Columns.Add("Name", Type.GetType("System.String"))
				filesTable.Columns.Add("LastWriteTime", Type.GetType("System.DateTime"))
		
				' Get File Info
				arrFileInfo = dirInfo.GetFiles("*.pdf")

				For Each filesInfo In arrFileInfo
					drFiles = filesTable.NewRow()
					drFiles("Name")          = filesInfo.Name
					drFiles("LastWriteTime") = filesInfo.LastWriteTime					
					filesTable.Rows.Add(drFiles)
				Next filesInfo
				
				dvFiles = filesTable.DefaultView
				dvFiles.Sort = "LastWriteTime DESC"
				
				dgFiles.DataSource = dvFiles
				dgFiles.DataBind()
			End Sub
		</script>
		<link href="http://intranet.talleyds.com/sklog/styles/tocDOC.css" type="text/css" rel="stylesheet">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<%
			Response.WriteFile ("../includes/qHeader.asp")		
		%>
		<p><a class="subDept" href="http://intranet.talleyds.com/viper/quality/ca/ca.asp">CORRECTIVE 
				AND PREVENTATIVE ACTION</a></p>
		<FORM>
			<asp:datagrid id="dgFiles" style="Z-INDEX: 101; LEFT: 20px; POSITION: absolute; TOP: 120px" 
			runat="server" CellPadding="5" CellSpacing="3" AutoGenerateColumns="False" ShowHeader="True" 
			Width="293px" AllowPaging="True" PageSize="40" OnPageIndexChanged="dgFiles_Paging">
				<ItemStyle Font-Size="XX-Small" Font-Names="Verdana" Font-Bold="True" ForeColor="#336699" BackColor="White"></ItemStyle>
				<HeaderStyle Font-Size="XX-Small" Font-Names="Verdana" Font-Bold="True" ForeColor="#660033" CssClass="TH"></HeaderStyle>
				<Columns>
					<asp:HyperLinkColumn DataNavigateUrlField="Name" target="_blank"
					DataNavigateUrlFormatString="http://intranet.talleyds.com/p1/Quality/Corr_Prev_Action_Cases/Opportunities for Improvement/Testing/{0}" 
					DataTextField="Name" HeaderText="Opportunities for Improvement - Testing"></asp:HyperLinkColumn>
					<asp:BoundColumn DataField="LastWriteTime" SortExpression="Date" Visible="False" HeaderText="File Last Modified" DataFormatString="{0:d}" />
				</Columns>
			</asp:datagrid>
		</FORM>
	</body>
</HTML>
 
I don't see anything glaring other than you aren't accepting the changes on your dataset or disposing your resoruces, but nothing that glares at me as something that would cause the problem. Maybe try accepting changes at the end of your custom Fill method you wrote... also trying doing an indexed loop instead of a for each and see if that is causing some sort or reference issue - shouldn't be, but I've seen stranger.
 
Back
Top