Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > HTML formatting question in datagrid pager area.

Reply
Thread Tools

HTML formatting question in datagrid pager area.

 
 
=?Utf-8?B?c3Ryb3V0?=
Guest
Posts: n/a
 
      01-13-2005
I know it's dumb ... sometimes frustrating

I want the text and a dropdownlist align with both side of a table cell,
i.e. text align left and dropdownlist align right. I cannot add more cells to
do format because it's in a Datagrid pager area. The html code generated for
pager is one sigle cell with lots of colspan.

I tried to add some html elements in between text and dropdownlist, for
example table iframe and p but I cannot achieve the exact result.

<td colspan="3" >1 2 3 4 5 6 <nobr><iframe width="70%" height="0"
style="display:inline"></iframe>
<select>
<option selected="selected" value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
</select></nobr></td>

Any help?

BTW my last question about adding dropdownlist to pager works fine. Thanks
the reply.
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      01-14-2005
Hi,

I think you have to control the column spans yourself. So, wipe out the
spans and insert your own cells. Here's the idea in code with comment
inline. Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
DataGrid1.AllowPaging = True
DataGrid1.PageSize = 3
If Not IsPostBack Then
DataGrid1.DataSource = CreateDataSource()
DataGrid1.DataBind()
End If
End Sub
Private Sub DataGrid1_ItemCreated _
(ByVal sender As Object, ByVal e As _
DataGridItemEventArgs) Handles DataGrid1.ItemCreated
' Insert text and ddl columns in the pager cell
' by Ken Cox - Microsoft MVP [ASP.NET]

' Check that we are dealing with the pager row
If e.Item.ItemType = ListItemType.Pager Then

' declare the variables we'll need
Dim lstItem As DataGridItem
Dim cmbBox As New DropDownList
Dim txtcell As New TableCell
Dim cmbcell As New TableCell
Dim oldcell As New TableCell
' Get a reference to the datagrid item (row)
lstItem = e.Item
' Get a reference to the current pager cell
oldcell = e.Item.Cells(0)
' Set the current pager cell to span two columns
oldcell.ColumnSpan = 2
' Align the pager elements to the centre
oldcell.HorizontalAlign = HorizontalAlign.Center
' Clear out existing cells in the pager
lstItem.Cells.Clear()
' Put some text in the text cell
txtcell.Text = "Text Here"

' Create a dropdownlist box and add some items
cmbBox.Items.Add("Red")
cmbBox.Items.Add("Green")
' Add the ddl to the controls collection
' of the cell
cmbcell.Controls.Add(cmbBox)
cmbcell.ColumnSpan = 1
' Set the cell alignment to right
cmbcell.HorizontalAlign = HorizontalAlign.Right

' Add the text cell to the datagrid item's Cells collection
lstItem.Cells.Add(txtcell)
' Add the original item to the Cells collection
lstItem.Cells.Add(oldcell)
' Add the cell with the ddl to the collection
lstItem.Cells.Add(cmbcell)

End If
End Sub


Function CreateDataSource() As ICollection
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("PercentValue", GetType(Double)))
dt.Columns.Add _
(New DataColumn("Boolean", GetType(Boolean)))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 0.23 * (i + 1)
dr(3) = True
dt.Rows.Add(dr)
Next i
Dim dv As New DataView(dt)
Return dv
End Function 'CreateDataSource

<asp:datagrid id="DataGrid1" runat="server"></asp:datagrid>



"strout" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I know it's dumb ... sometimes frustrating
>
> I want the text and a dropdownlist align with both side of a table cell,
> i.e. text align left and dropdownlist align right. I cannot add more cells
> to
> do format because it's in a Datagrid pager area. The html code generated
> for
> pager is one sigle cell with lots of colspan.
>
> I tried to add some html elements in between text and dropdownlist, for
> example table iframe and p but I cannot achieve the exact result.
>
> <td colspan="3" >1 2 3 4 5 6 <nobr><iframe width="70%" height="0"
> style="display:inline"></iframe>
> <select>
> <option selected="selected" value="10">10</option>
> <option value="25">25</option>
> <option value="50">50</option>
> </select></nobr></td>
>
> Any help?
>
> BTW my last question about adding dropdownlist to pager works fine. Thanks
> the reply.


 
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
pager message formatting ucp with pocsag encoding Ronald Rood Perl Misc 1 02-10-2005 01:52 PM
Datagrid & pager Ben ASP .Net 2 07-16-2004 03:16 AM
Datagrid's pager style Mark Warner ASP .Net 1 02-27-2004 04:52 AM
DataGrid and ItemCreated and Pager Binny ASP .Net 2 12-10-2003 06:38 PM
pager in datagrid kgs ASP .Net 1 11-27-2003 12:40 PM



Advertisments