lorena
Well-known member
I have two identical pages that list out the contents of two different folders with hyperlinks to each file. One works, the other doesnt. On the one that doesnt 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 doesnt 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 dont get it.
Here is all of my code:
"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 doesnt 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 dont get it.
Here is all of my code:
Code:
<%@ 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>