G
Garth Wells
I used the following "classic ASP" approach to build a dynamic menu, but would
like to know
the proper way to implement the same functionality using a .Net technique (e.g.,
placing the
code in the .cs file and dynamically building the hyperlink controls). The
controls need to
appear within the same <TD>, separated by two spaces
Thanks for your help
-----
<%@ Import Namespace="Microsoft.Practices.EnterpriseLibrary.Data" %>
<%@ Import Namespace="Microsoft.Practices.EnterpriseLibrary.Data.Sql" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Common" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MenuSub.ascx.cs"
Inherits="SubMenu" %>
<table id="table1" cellSpacing="0" cellPadding="0" width="900" border="0">
<TR bgColor="#2a69b3">
<TD vAlign="middle" align="center" width="900" height="20">
<%
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "pr_MenuSub_SELECT";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
db.AddInParameter(dbCommand, "MM_Description", DbType.String, "HR");
using (IDataReader dataReader = db.ExecuteReader(dbCommand))
{
while (dataReader.Read())
{
// Get the value of the Name column in the DbDataReader.
Response.Write("<a href=" +
dataReader["MS_Page"].ToString() + ">" + dataReader["MS_Description"].ToString()
+ "</href>");
Response.Write(" ");
}
}
%>
</TD>
</TR>
</table>
like to know
the proper way to implement the same functionality using a .Net technique (e.g.,
placing the
code in the .cs file and dynamically building the hyperlink controls). The
controls need to
appear within the same <TD>, separated by two spaces
Thanks for your help
-----
<%@ Import Namespace="Microsoft.Practices.EnterpriseLibrary.Data" %>
<%@ Import Namespace="Microsoft.Practices.EnterpriseLibrary.Data.Sql" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Common" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MenuSub.ascx.cs"
Inherits="SubMenu" %>
<table id="table1" cellSpacing="0" cellPadding="0" width="900" border="0">
<TR bgColor="#2a69b3">
<TD vAlign="middle" align="center" width="900" height="20">
<%
Database db = DatabaseFactory.CreateDatabase();
string sqlCommand = "pr_MenuSub_SELECT";
DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
db.AddInParameter(dbCommand, "MM_Description", DbType.String, "HR");
using (IDataReader dataReader = db.ExecuteReader(dbCommand))
{
while (dataReader.Read())
{
// Get the value of the Name column in the DbDataReader.
Response.Write("<a href=" +
dataReader["MS_Page"].ToString() + ">" + dataReader["MS_Description"].ToString()
+ "</href>");
Response.Write(" ");
}
}
%>
</TD>
</TR>
</table>