Por favor akguien me ayudeeeeee
Publicado por Martin (18 intervenciones) el 10/08/2006 17:20:32
POR ALGUIEN ME AYUDE OBSERVEN ESTE CODIGO ES PARA GENERAR CONTROLADORES DINAMICAMENTE PERO SOLO ME MUESTRA UNO DE LOS CONTROLADORES PARA SER MAS ESPECIFICO SOLO EL objRLabel GRACIAS DE VERDAD MI TRABAJO DEPENDE DE ESTO
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Public Class index
Inherits System.Web.UI.Page
Protected WithEvents objLabel As System.Web.UI.WebControls.Label
Protected WithEvents objBLabel As System.Web.UI.WebControls.Label
Protected WithEvents objRLabel As System.Web.UI.WebControls.Label
Protected WithEvents objImage As System.Web.UI.WebControls.Image
Protected WithEvents objHplnk As System.Web.UI.WebControls.HyperLink
Private strConn As String
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
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()
strConn = "Data Source=SBG-Y0BIUCUYDAG;Initial Catalog=NOMBRE;Integrated Security=True"
End Sub
#End Region
Protected Sub Page_Load_Noticias(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'For i = 1 To 3 'for para hacer el control en BD de q se escoja una a una las imagenes
Dim objCell As TableCell
Dim objRow As TableRow
Dim B2eDataNoticias As SqlConnection = New SqlConnection(strConn)
B2eDataNoticias.Open()
Dim commandString As String = "select * from NOTICIA where Estatus = 'N' "
Dim dbCommand As SqlCommand = New SqlCommand(commandString, B2eDataNoticias)
Dim Reader As SqlDataReader
Reader = dbCommand.ExecuteReader()
tblNoticias.Rows.Clear()
While Reader.Read
If Reader("imagen") Is DBNull.Value Then
objLabel = New Label()
objLabel.ID = "lblNoti" & "_" & CStr(Reader("idnoticia"))
objLabel.Text = CStr(Reader("Titulo"))
objLabel.CssClass = "LabelTitulo"
objBLabel = New Label()
objBLabel.ID = "lblBNoti" & "_" & CStr(Reader("idnoticia"))
objBLabel.Text = CStr(Reader("Bresumen"))
objBLabel.CssClass = "LabelBResumen"
objRLabel = New Label()
objRLabel.ID = "lblRNoti" & "_" & CStr(Reader("idnoticia"))
objRLabel.Text = CStr(Reader("Resumen"))
objRLabel.CssClass = "LabelResumen"
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objLabel)
objCell.Width = Unit.Percentage(100%)
objCell.Height = Unit.Percentage(10%)
objRow.Cells.Add(objCell)
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objBLabel)
objCell.Width = Unit.Percentage(100%)
objCell.Height = Unit.Percentage(40%)
objRow.Cells.Add(objCell)
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objRLabel)
objCell.Width = Unit.Percentage(100%)
objCell.Height = Unit.Percentage(40%)
objRow.Cells.Add(objCell)
tblNoticias.Rows.Add(objRow)
tblNoticias.Rows.Add(objRow)
tblNoticias.Rows.Add(objRow)
Else
objImage = New Image()
objImage.ID = "ImgNoti" & "_" & CStr(Reader("idnoticia"))
objImage.ImageUrl = CStr(Reader("imagen"))
objLabel = New Label()
objLabel.ID = "lblNoti" & "_" & CStr(Reader("idnoticia"))
objLabel.Text = CStr(Reader("Titulo"))
objLabel.CssClass = "LabelTitulo"
objBLabel = New Label()
objBLabel.ID = "lblBNoti" & "_" & CStr(Reader("idnoticia"))
objBLabel.Text = CStr(Reader("BResumen"))
objBLabel.CssClass = "LabelBResumen"
objRLabel = New Label()
objRLabel.ID = "lblRNoti" & "_" & CStr(Reader("idnoticia"))
objRLabel.Text = CStr(Reader("Resumen"))
objRLabel.CssClass = "LabelResumen"
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objImage)
objRow.Cells.Add(objCell)
objCell = New TableCell()
objCell.Controls.Add(objLabel)
objRow.Cells.Add(objCell)
objCell = New TableCell()
objCell.Controls.Add(objBLabel)
objRow.Cells.Add(objCell)
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objRLabel)
objRow.Cells.Add(objCell)
tblNoticias.Rows.Add(objRow)
End If
End While
B2eDataNoticias.Close()
B2eDataNoticias = Nothing
dbCommand = Nothing
End Sub
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Public Class index
Inherits System.Web.UI.Page
Protected WithEvents objLabel As System.Web.UI.WebControls.Label
Protected WithEvents objBLabel As System.Web.UI.WebControls.Label
Protected WithEvents objRLabel As System.Web.UI.WebControls.Label
Protected WithEvents objImage As System.Web.UI.WebControls.Image
Protected WithEvents objHplnk As System.Web.UI.WebControls.HyperLink
Private strConn As String
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
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()
strConn = "Data Source=SBG-Y0BIUCUYDAG;Initial Catalog=NOMBRE;Integrated Security=True"
End Sub
#End Region
Protected Sub Page_Load_Noticias(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'For i = 1 To 3 'for para hacer el control en BD de q se escoja una a una las imagenes
Dim objCell As TableCell
Dim objRow As TableRow
Dim B2eDataNoticias As SqlConnection = New SqlConnection(strConn)
B2eDataNoticias.Open()
Dim commandString As String = "select * from NOTICIA where Estatus = 'N' "
Dim dbCommand As SqlCommand = New SqlCommand(commandString, B2eDataNoticias)
Dim Reader As SqlDataReader
Reader = dbCommand.ExecuteReader()
tblNoticias.Rows.Clear()
While Reader.Read
If Reader("imagen") Is DBNull.Value Then
objLabel = New Label()
objLabel.ID = "lblNoti" & "_" & CStr(Reader("idnoticia"))
objLabel.Text = CStr(Reader("Titulo"))
objLabel.CssClass = "LabelTitulo"
objBLabel = New Label()
objBLabel.ID = "lblBNoti" & "_" & CStr(Reader("idnoticia"))
objBLabel.Text = CStr(Reader("Bresumen"))
objBLabel.CssClass = "LabelBResumen"
objRLabel = New Label()
objRLabel.ID = "lblRNoti" & "_" & CStr(Reader("idnoticia"))
objRLabel.Text = CStr(Reader("Resumen"))
objRLabel.CssClass = "LabelResumen"
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objLabel)
objCell.Width = Unit.Percentage(100%)
objCell.Height = Unit.Percentage(10%)
objRow.Cells.Add(objCell)
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objBLabel)
objCell.Width = Unit.Percentage(100%)
objCell.Height = Unit.Percentage(40%)
objRow.Cells.Add(objCell)
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objRLabel)
objCell.Width = Unit.Percentage(100%)
objCell.Height = Unit.Percentage(40%)
objRow.Cells.Add(objCell)
tblNoticias.Rows.Add(objRow)
tblNoticias.Rows.Add(objRow)
tblNoticias.Rows.Add(objRow)
Else
objImage = New Image()
objImage.ID = "ImgNoti" & "_" & CStr(Reader("idnoticia"))
objImage.ImageUrl = CStr(Reader("imagen"))
objLabel = New Label()
objLabel.ID = "lblNoti" & "_" & CStr(Reader("idnoticia"))
objLabel.Text = CStr(Reader("Titulo"))
objLabel.CssClass = "LabelTitulo"
objBLabel = New Label()
objBLabel.ID = "lblBNoti" & "_" & CStr(Reader("idnoticia"))
objBLabel.Text = CStr(Reader("BResumen"))
objBLabel.CssClass = "LabelBResumen"
objRLabel = New Label()
objRLabel.ID = "lblRNoti" & "_" & CStr(Reader("idnoticia"))
objRLabel.Text = CStr(Reader("Resumen"))
objRLabel.CssClass = "LabelResumen"
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objImage)
objRow.Cells.Add(objCell)
objCell = New TableCell()
objCell.Controls.Add(objLabel)
objRow.Cells.Add(objCell)
objCell = New TableCell()
objCell.Controls.Add(objBLabel)
objRow.Cells.Add(objCell)
objRow = New TableRow()
objCell = New TableCell()
objCell.Controls.Add(objRLabel)
objRow.Cells.Add(objCell)
tblNoticias.Rows.Add(objRow)
End If
End While
B2eDataNoticias.Close()
B2eDataNoticias = Nothing
dbCommand = Nothing
End Sub
Valora esta pregunta
0