Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Server created pages

Reply
Thread Tools

Server created pages

 
 
=?Utf-8?B?SmVyZW15IEJydWVuaW5n?=
Guest
Posts: n/a
 
      02-20-2007
I have found numerous iterations of server classes creating controls and
adding them to web pages. However, I have never found any uses with the
databind. I would like to set the text of the object to a databind call, not
just a string value.

Textbox1.Text = <%# DataBind.Eval("Col001")%>

The key to my design is; the class determines the controls needed from the
SQL view that is presented to the page. This would allow me to custom design
the view to 2,3,4, 10,20 columns/controls, but use only one page for data
presentation. And allow the user to page thru the results without having to
rebuild the page.

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      02-20-2007
Instead of using simple binding, bind to the column, by index, in the
background.

TextBox1.Text = DataSet.Rows[0][0]; //second 0 = column

This gives you the ability to create the form, on the fly, and fill the
textboxes as needed. And, if you pull the name of the column, you can even
label it.

Or, you can create your own composite control, with a label and textbox and
feed the two values as you add it. Then, you can easily spin through a for
loop and add everything in the dataset, with proper column names.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

********************************************
Think outside the box!
********************************************
"Jeremy Bruening" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
>I have found numerous iterations of server classes creating controls and
> adding them to web pages. However, I have never found any uses with the
> databind. I would like to set the text of the object to a databind call,
> not
> just a string value.
>
> Textbox1.Text = <%# DataBind.Eval("Col001")%>
>
> The key to my design is; the class determines the controls needed from the
> SQL view that is presented to the page. This would allow me to custom
> design
> the view to 2,3,4, 10,20 columns/controls, but use only one page for data
> presentation. And allow the user to page thru the results without having
> to
> rebuild the page.
>


 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmVyZW15IEJydWVuaW5n?=
Guest
Posts: n/a
 
      02-20-2007
One clarification.

I have not loaded the actual dataset, yet. I am loading the view structure
to determine the layout and controls needed. The Databind will function will
call the class which will actually load the data onto the web form.

Code snip of the panel builder (not complete, and in early development):

Caller would on page_Int would be: Builder.CreateFormPanel(me, 'vw_abc')
***START HERE
Public Function CreateFormPanel(ByVal objPage As Page, ByVal
LayoutBasedOn As String) As Boolean
Dim MySize As New dbTable

ParentPage = objPage

With MySize
.ViewtoLoad = "[aspnet_!PanelLayout]"
.FiltertoView = LayoutBasedOn
If .OpenResults Then
Dim MyTable As Table = CreateTable()

Do Until .EOF
Dim pstrCaption As String =
ParseString(.mData.GetProperty("ID")) & ":"
Dim pstrTag As String = .mData.GetProperty("ID")
Dim pstrType As String =
..mData.GetProperty("DataType")
Dim pintLength As Integer =
..mData.GetProperty("Length")
Dim pintScale As Integer =
..mData.GetProperty("Scale")
Dim pintAllowNulls As Integer =
..mData.GetProperty("AllowNulls")

If pstrTag.ToUpper = "DELETED" Then pstrType =
"bit"

If pstrCaption.StartsWith("_header") Then
MyTable.Rows.Add(CreateHeaderRow(pstrTag,
pstrCaption))
Else
MyTable.Rows.Add(CreateDataRow(pstrTag,
pstrCaption, pstrType, pintLength, pintScale, pintAllowNulls))
End If

.MoveNext()
Loop

MyTable.Rows.Add(CreateValidationRow)
MyTable.Rows.Add(CreateButtonRow("Form"))

_newpanel = CreatePanel()

_newpanel.Controls.Add(MyTable)

.CloseRecordSet()
End If
End With

Return True

End Function


Private Function CreatePanel(Optional ByVal NoFill As Boolean =
False) As Panel
Dim oPanel As Panel = New Panel

'Default Panel Properties
With oPanel
.Style("position") = "relative"
.BorderColor = System.Drawing.SystemColors.ActiveBorder
.BorderStyle = BorderStyle.Ridge
.BorderWidth = Unit.Pixel(1)
If Not NoFill Then
.Width = Unit.Percentage(100)
.Height = Unit.Percentage(100)
.ScrollBars = ScrollBars.Vertical
Else
.Width = Unit.Pixel(10)
.Height = Unit.Pixel(10)
.ScrollBars = ScrollBars.None
End If
End With

Return oPanel
End Function

Private Function CreateTable() As Table
Dim tbNew As Table = New Table

With tbNew
.ID = "tableData"
.Rows.Clear()
.BorderWidth = 0
.BorderColor = Drawing.Color.Black
.CellPadding = 1
.CellSpacing = 0
.Height = Unit.Percentage(100)
.Width = Unit.Percentage(100)
.Style("Postion") = "table-layout:fixed"
End With

Return tbNew
End Function

Private Function CreateHeaderRow(ByVal TagID As String, ByVal
CaptionID As String) As TableRow
Dim tbRow As TableRow = New TableRow
tbRow.ID = "th" & TagID
tbRow.Height = 10

Dim tbLabelCell As New TableCell
tbLabelCell.ID = "td" & TagID
tbLabelCell.ColumnSpan = 2
tbLabelCell.BackColor = Drawing.Color.RoyalBlue
tbLabelCell.ForeColor = Drawing.Color.White
tbLabelCell.Font.Bold = True
tbLabelCell.Font.Size = FontUnit.Medium
tbLabelCell.Controls.Add(CreateLabel(CaptionID, TagID, True))
tbRow.Cells.Add(tbLabelCell)

If (TagID = "_header0" Or TagID = "_header99") Then
isReadOnly = True
Else
isReadOnly = False
End If

Return tbRow
End Function

Private Function CreateDataRow(ByVal TagID As String, ByVal
CaptionID As String, ByVal DataType As String, _
Optional ByVal FieldLength As Integer = 10,
Optional ByVal FieldScale As Integer = 0, _
Optional ByVal AllowNulls As Integer = 0) As
TableRow
Dim CheckIt As clsComboLoader = Nothing
Dim tbRow As TableRow = New TableRow
Dim pintColumns As Integer = FieldLength
Dim pintRows As Integer = 1

tbRow.ID = "tr" & TagID
tbRow.Height = 10

pintColumns *= 10
If pintColumns > MaxWidth Then
pintRows = pintColumns / MaxWidth
If pintRows > MaxRows Then pintRows = MaxRows
pintColumns = MaxWidth
ElseIf pintColumns < MinWidth Then
pintColumns = MinWidth
End If

Dim tbLabelCell As New TableCell
tbLabelCell.ID = "tdlbl" & TagID
tbLabelCell.Width = Unit.Percentage(25)
tbLabelCell.Controls.Add(CreateLabel(CaptionID, TagID))
tbRow.Cells.Add(tbLabelCell)

Dim tbTextCell As New TableCell
tbTextCell.ID = "td" & TagID
tbTextCell.Width = Unit.Percentage(75)

Select Case DataType.ToUpper
Case "DATETIME"
If TagID.ToUpper = "LASTMODIFIED" Then
tbTextCell.Controls.Add(CreateDateTimeBox(TagID))
ElseIf TagID.ToUpper.Contains("TIME") Then
tbTextCell.Controls.Add(CreateTimeBox(TagID))
Else
tbTextCell.Controls.Add(CreateDateBox(TagID))
End If
Case "INT", "SMALLINT", "TINYINT", "BIGINT"
tbTextCell.Controls.Add(CreateIntegerBox(TagID,
FieldLength))
Case "MONEY"
tbTextCell.Controls.Add(CreateCurrencyBox(TagID))
Case "NUMERIC"
tbTextCell.Controls.Add(CreateNumberBox(TagID,
FieldLength, FieldScale))
Case "BIT"
tbTextCell.Controls.Add(CreateCheckBox(TagID))
Case "CHAR", "VARCHAR", "NVARCHAR"
If Not isReadOnly Then
CheckIt = New clsComboLoader
If CheckIt.LoadDropDown(TagID, FieldLength) Then
tbTextCell.Controls.Add(CreateComboBox(TagID,
FieldLength))
Else
tbTextCell.Controls.Add(CreateTextBox(TagID,
FieldLength, pintColumns, pintRows))
End If
CheckIt = Nothing
Else
tbTextCell.Controls.Add(CreateTextBox(TagID,
FieldLength, pintColumns, pintRows))
End If
Case "TEXT"
tbTextCell.Controls.Add(CreateTextBox(TagID,
FieldLength, pintColumns, pintRows))
Case Else
WriteInformation(DataType.ToUpper, 522)
End Select

If AllowNulls <> 0 Then
tbTextCell.Controls.Add(BuildFieldValidator(strPre fix &
TagID))
End If

tbRow.Cells.Add(tbTextCell)

Return tbRow
End Function

Private Function CreateTextBox(ByVal TagID As String, ByVal
ValueLength As Integer, Optional ByVal BoxWidth As Integer = 40, Optional
ByVal BoxHeight As Integer = 1) As WebInput
Dim txtInput As WebInput = New ISNet.WebUI.WebControls.WebInput

Dim pstrFormat As String = ">&<"
For I As Integer = 2 To ValueLength
pstrFormat += "C"
Next I

strPrefix = "txt"
txtInput.ID = strPrefix & TagID
txtInput.AcceptEnter = False
txtInput.CaseSentitive = True
txtInput.Height = BoxHeight * 20
txtInput.HighLight.Type = HighLightType.Character
txtInput.MaxLength = ValueLength
txtInput.ReadOnly = isReadOnly
txtInput.Rows = BoxHeight
If BoxHeight = 1 Then
txtInput.TextMode = WebControls.TextBoxMode.SingleLine
Else
txtInput.TextMode = WebControls.TextBoxMode.MultiLine
End If
txtInput.Width = BoxWidth
txtInput.Attributes.Add("Tag", TagID)

'Dim MyTag2Be As String = "<%# Dataform.Record(""" & TagID &
""")%>"
'txtInput.Text = MyTag2Be.ToString

Return txtInput
End Function
*** END HERE


"Cowboy (Gregory A. Beamer)" wrote:

> Instead of using simple binding, bind to the column, by index, in the
> background.
>
> TextBox1.Text = DataSet.Rows[0][0]; //second 0 = column
>
> This gives you the ability to create the form, on the fly, and fill the
> textboxes as needed. And, if you pull the name of the column, you can even
> label it.
>
> Or, you can create your own composite control, with a label and textbox and
> feed the two values as you add it. Then, you can easily spin through a for
> loop and add everything in the dataset, with proper column names.
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> http://gregorybeamer.spaces.live.com
>
> ********************************************
> Think outside the box!
> ********************************************
> "Jeremy Bruening" <(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
> >I have found numerous iterations of server classes creating controls and
> > adding them to web pages. However, I have never found any uses with the
> > databind. I would like to set the text of the object to a databind call,
> > not
> > just a string value.
> >
> > Textbox1.Text = <%# DataBind.Eval("Col001")%>
> >
> > The key to my design is; the class determines the controls needed from the
> > SQL view that is presented to the page. This would allow me to custom
> > design
> > the view to 2,3,4, 10,20 columns/controls, but use only one page for data
> > presentation. And allow the user to page thru the results without having
> > to
> > rebuild the page.
> >

>

 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      02-20-2007
Textboxes do not support databinding, they must be contained in a
control that does. a formview will probably do what you want or you can
write your own.

-- bruce (sqlwork.com)

Jeremy Bruening wrote:
> I have found numerous iterations of server classes creating controls and
> adding them to web pages. However, I have never found any uses with the
> databind. I would like to set the text of the object to a databind call, not
> just a string value.
>
> Textbox1.Text = <%# DataBind.Eval("Col001")%>
>
> The key to my design is; the class determines the controls needed from the
> SQL view that is presented to the page. This would allow me to custom design
> the view to 2,3,4, 10,20 columns/controls, but use only one page for data
> presentation. And allow the user to page thru the results without having to
> rebuild the page.
>

 
Reply With Quote
 
=?Utf-8?B?SmVyZW15IEJydWVuaW5n?=
Guest
Posts: n/a
 
      02-21-2007
I should not have said Textbox (generalization). It is actually a webinput
control, which does support databinding.

"bruce barker" wrote:

> Textboxes do not support databinding, they must be contained in a
> control that does. a formview will probably do what you want or you can
> write your own.
>
> -- bruce (sqlwork.com)
>
> Jeremy Bruening wrote:
> > I have found numerous iterations of server classes creating controls and
> > adding them to web pages. However, I have never found any uses with the
> > databind. I would like to set the text of the object to a databind call, not
> > just a string value.
> >
> > Textbox1.Text = <%# DataBind.Eval("Col001")%>
> >
> > The key to my design is; the class determines the controls needed from the
> > SQL view that is presented to the page. This would allow me to custom design
> > the view to 2,3,4, 10,20 columns/controls, but use only one page for data
> > presentation. And allow the user to page thru the results without having to
> > rebuild the page.
> >

>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
aspnet.mdf file still is created even though i created a custom provider? Sunfire ASP .Net 1 11-10-2007 04:30 AM
OleDbDataAdapter created in code behaves differently from one created by wizard. tom c ASP .Net 6 09-06-2006 04:46 PM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
are the objects created in the stack guarranted to have been created? jimjim C++ 12 06-03-2005 12:57 PM
schemalocation entry in XML created by castor created sources? Ulf Heyder XML 0 10-16-2003 02:14 PM



Advertisments