spasibo za otziv!
Зачем тут Dynamic LinkButton не понятно, ну и ладно ...
Как сделана сама tablisa ?
Tablisa sdelana na VB.net-e s ispolzovaniem HTML tegov
Vot ishodniy kod (recipes.aspx):
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="reicepes.aspx.vb" Inherits="CookWell.Recipes"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Recipes</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<span id="span_ListRecipes" runat="server"></span>
</form>
</body>
</HTML>
Vot ishodniy kod (recipes.aspx.vb):
Imports System.Data
Public Class Recipes
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents span_ListRecipes As System.Web.UI.HtmlControls.HtmlGenericControl
Protected WithEvents LB_OpenContent As System.Web.UI.WebControls.LinkButton
Protected WithEvents DataList1 As System.Web.UI.WebControls.DataList
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack() Then
span_ListRecipes.InnerHtml = GetReciepes()
End If
End Sub
Private Function GetReciepes() As String
Dim strQuery As String = "SELECT * FROM WellProgram.T_CookWellReceipes ORDER BY DayTime, WeekDay"
Dim da As New SqlClient.SqlDataAdapter(strQuery, ConfigurationSettings.AppSettings("Conn_WellProgram"))
Dim tbl As New DataTable
Dim strHTML As String = String.Empty
da.Fill(tbl)
' Header
'strHTML += "<table border = 1><tr><td>ID</td><td>Label</td><td>WeekDay</td><td>dayTime</td></tr>"
'For Each row As DataRow In tbl.Select("DayTime = 'BreakFast'")
'strHTML += "<tr>"
'strHTML += "<td>" + row("ID").ToString + "</td>"
'strHTML += "<td>" + row("Label").ToString + "</td>"
'strHTML += "<td>" + row("WeekDay").ToString + "</td>"
'strHTML += "<td>" + row("DayTime").ToString + "</td>"
'strHTML += "</tr>"
'Next
'strHTML += "</Table>"
strHTML += "<HR>"
' Header
strHTML += "<table border = 1><tr><td></td>"
' Day i
Dim i As Integer = 1
While i < 8
strHTML += "<td><b><center>Day " & i & "</center></b></td>"
i += 1
End While
' Breakfast
strHTML += "<tr><td><b>BreakFast</b></TD>"
For Each row As DataRow In tbl.Select("DayTime = 'BreakFast'")
Dim lb As New LinkButton
'With lb
' .ID = "lb_" & row("WeekDay").tostring.Replace("Day", String.Empty).Trim
' .Text = "..."
'End With
strHTML += "<td>" & row("Label").ToString & "</td>"
Next
' Snack1
strHTML += "<tr><td><b>Snack</b></TD>"
For Each row As DataRow In tbl.Select("DayTime = 'Snack1'")
Dim lb As New LinkButton
'With lb
' .ID = "lb_" & row("WeekDay").tostring.Replace("Day", String.Empty).Trim
' .Text = "..."
'End With
strHTML += "<td>" & row("Label").ToString & "</td>"
Next
' Snack1
strHTML += "<tr><td><b>Lunch</b></TD>"
For Each row As DataRow In tbl.Select("DayTime = 'Lunch'")
Dim lb As New LinkButton
'With lb
' .ID = "lb_" & row("WeekDay").tostring.Replace("Day", String.Empty).Trim
' .Text = "..."
'End With
strHTML += "<td>" & row("Label").ToString & "</td>"
Next
' Snack1
strHTML += "<tr><td><b>Snack</b></TD>"
For Each row As DataRow In tbl.Select("DayTime = 'Snack2'")
Dim lb As New LinkButton
'With lb
' .ID = "lb_" & row("WeekDay").tostring.Replace("Day", String.Empty).Trim
' .Text = "..."
'End With
strHTML += "<td>" & row("Label").ToString & "</td>"
Next
' Snack1
strHTML += "<tr><td><b>Dinner</b></TD>"
For Each row As DataRow In tbl.Select("DayTime = 'Dinner'")
Dim lb As New LinkButton
'With lb
' .ID = "lb_" & row("WeekDay").tostring.Replace("Day", String.Empty).Trim
' .Text = "..."
'End With
strHTML += "<td>" & row("Label").ToString & "</td>"
Next
' End of the table
strHTML += "</tr></Table>"
GetReciepes = strHTML
tbl.Dispose()
da.Dispose()
End Function
Private Sub LB_OpenContent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LB_OpenContent.Click
Dim strQuery As String = "SELECT TOP 1 * FROM WellProgram.T_CookWellReceipes ORDER BY DayTime, WeekDay"
Dim da As New SqlClient.SqlDataAdapter(strQuery, ConfigurationSettings.AppSettings("Conn_WellProgram"))
Dim tbl As New DataTable
Dim strHTML As String = String.Empty
da.Fill(tbl)
Session("RecipesContent") = tbl.Rows(0)("Content").ToString
Response.Redirect("ContentRecipes.aspx")
tbl.Dispose()
da.Dispose()
End Sub
End Class