I have a datagrid where each column has both a label and a linkbutton.
I need to have the label left justified and the linkbutton right justified.
In HTML, I would have to set up 2 cells to do this.
Is there a way to accomplish this in a DataGrid (and have the text span both
columns).
What I have is:
<asp:TemplateColumn Visible="true" headerText="Bundle(10):"
ItemStyle-Width="100" ItemStyle-VerticalAlign="Top">
<itemtemplate>
<asp:Label ID="Bundle10" text='<%#
String.Format("{0:$#,##0}",Container.DataItem("Bun dle(10)"))%>'
runat="server"/>
<asp:linkButton ID="Bundle10Link" text='Buy' runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
I could make this into 2 TemplateColumns and but the HeaderText would only
be over the 1st column. There is no Header-Colspan attribute.
I also tried to have 2 itemTemplates inside the TemplateColumn, but I guess
you can't do that, as when I tried it, it only showed the 2nd itemTemplate.
Thanks,
Tom 6 2178
"tshad" <ts**********@ftsolutions.com> wrote in
news:uM**************@TK2MSFTNGP09.phx.gbl: I have a datagrid where each column has both a label and a linkbutton.
I need to have the label left justified and the linkbutton right justified. In HTML, I would have to set up 2 cells to do this.
Is there a way to accomplish this in a DataGrid (and have the text span both columns).
You do this type of formatting in the OnItemDataBound Event.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying. http://members.ebay.com/aboutme/coolspot18/
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@127.0.0.1... "tshad" <ts**********@ftsolutions.com> wrote in news:uM**************@TK2MSFTNGP09.phx.gbl:
I have a datagrid where each column has both a label and a linkbutton.
I need to have the label left justified and the linkbutton right justified. In HTML, I would have to set up 2 cells to do this.
Is there a way to accomplish this in a DataGrid (and have the text span both columns). You do this type of formatting in the OnItemDataBound Event.
But that is my problem.
How would I do it?
If it puts the label and linkbutton in the same cell, how do you tell it to
align 1 left and 1 right?
Or if you use 2 templateColumns, how do you tell the header to span 2
columns?
Thanks,
Tom -- Lucas Tam (RE********@rogers.com) Please delete "REMOVE" from the e-mail address when replying. http://members.ebay.com/aboutme/coolspot18/
"tshad" <ts**********@ftsolutions.com> wrote in
news:et**************@tk2msftngp13.phx.gbl: If it puts the label and linkbutton in the same cell, how do you tell it to align 1 left and 1 right?
You'll need to use CSS to align 2 items with 2 different alignments in the
same cell.
Otherwise use 2 cells (columns).
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying. http://members.ebay.com/aboutme/coolspot18/
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@127.0.0.1... "tshad" <ts**********@ftsolutions.com> wrote in news:et**************@tk2msftngp13.phx.gbl:
If it puts the label and linkbutton in the same cell, how do you tell it to align 1 left and 1 right? You'll need to use CSS to align 2 items with 2 different alignments in the same cell.
I tried that:
Here is the template Column:
<asp:TemplateColumn Visible="true" headerText="Bundle(10):"
ItemStyle-Width="90" ItemStyle-VerticalAlign="Top">
<itemtemplate>
<asp:Label ID="Bundle10ID" visible="false" text='<%#
Container.DataItem("Bundle(10)ID")%>' runat="server"/>
<asp:Label ID="Bundle10" CssClass="onleft" text='<%#
String.Format("{0:$#,##0}",Container.DataItem("Bun dle(10)"))%>'
runat="server"/>
<asp:linkButton ID="Bundle10Link" CssClass="onright"
OnClick="GetPrice" text='Buy' runat="server"/>
</itemtemplate>
Here is the CSS:
..onright {text-align:right}
..onleft {text-align:left}
Here is the output:
<td valign="Top" style="width:90px;">
<span id="JobPostingGrid__ctl3_Bundle10"
class="onleft">$1,400</span>
<a id="JobPostingGrid__ctl3_Bundle10Link" class="onright"
href="javascript:__doPostBack('JobPostingGrid$_ctl 3$Bundle10Link','')">Buy</a>
</td>
But it just puts the 2 objects next to each other.
Am I using the wrong CSS? Otherwise use 2 cells (columns).
Problem is the Header.
Thanks,
Tom -- Lucas Tam (RE********@rogers.com) Please delete "REMOVE" from the e-mail address when replying. http://members.ebay.com/aboutme/coolspot18/
read this - it might help http://www.codeproject.com/aspnet/Me...gridHeader.asp
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl... I have a datagrid where each column has both a label and a linkbutton.
I need to have the label left justified and the linkbutton right justified. In HTML, I would have to set up 2 cells to do this.
Is there a way to accomplish this in a DataGrid (and have the text span both columns).
What I have is:
<asp:TemplateColumn Visible="true" headerText="Bundle(10):" ItemStyle-Width="100" ItemStyle-VerticalAlign="Top"> <itemtemplate> <asp:Label ID="Bundle10" text='<%# String.Format("{0:$#,##0}",Container.DataItem("Bun dle(10)"))%>' runat="server"/> <asp:linkButton ID="Bundle10Link" text='Buy' runat="server"/> </itemtemplate> </asp:TemplateColumn>
I could make this into 2 TemplateColumns and but the HeaderText would only be over the 1st column. There is no Header-Colspan attribute.
I also tried to have 2 itemTemplates inside the TemplateColumn, but I guess you can't do that, as when I tried it, it only showed the 2nd itemTemplate.
Thanks,
Tom
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl... read this - it might help
http://www.codeproject.com/aspnet/Me...gridHeader.asp
That's great.
I didn't know you could muck around with the headers like that.
The way I was going to solve it was to create a separate table just for the
header (which also works), but this is definately a more elegant method.
Solves the problem.
Thanks,
Tom -- Regards
John Timney ASP.NET MVP Microsoft Regional Director
"tshad" <ts**********@ftsolutions.com> wrote in message news:uM**************@TK2MSFTNGP09.phx.gbl...I have a datagrid where each column has both a label and a linkbutton.
I need to have the label left justified and the linkbutton right justified. In HTML, I would have to set up 2 cells to do this.
Is there a way to accomplish this in a DataGrid (and have the text span both columns).
What I have is:
<asp:TemplateColumn Visible="true" headerText="Bundle(10):" ItemStyle-Width="100" ItemStyle-VerticalAlign="Top"> <itemtemplate> <asp:Label ID="Bundle10" text='<%# String.Format("{0:$#,##0}",Container.DataItem("Bun dle(10)"))%>' runat="server"/> <asp:linkButton ID="Bundle10Link" text='Buy' runat="server"/> </itemtemplate> </asp:TemplateColumn>
I could make this into 2 TemplateColumns and but the HeaderText would only be over the 1st column. There is no Header-Colspan attribute.
I also tried to have 2 itemTemplates inside the TemplateColumn, but I guess you can't do that, as when I tried it, it only showed the 2nd itemTemplate.
Thanks,
Tom
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Billy Jacobs |
last post by:
I am using a datagrid to display some data. I need to
create 2 header rows for this grid with columns of
varying spans. In html it would be the following.
<Table>
<tr>
<td colspan=8>Official...
|
by: Alan Lambert |
last post by:
I am writing a web-based reporting tool and using a datagrid to display
information returned from a database.
I am displaying column headings from bound columns with no problems but I
need to...
|
by: Alejandro Penate-Diaz |
last post by:
I have a datagrid inside a table and I want to fix both (table and databrid)
width to 700, but when the content of datagrid is too large the width
increases automatically sometimes and sometimes...
|
by: sri_san |
last post by:
Hello,
I have a datagrid in which the header needs to span over 2
columns. I have tried creating a tableCells and tableRow at runtime and
set the columnspan property of a cell to 2. But, the...
|
by: Olav Tollefsen |
last post by:
Is it possible to create a DataGrid footer to span multiple columns?
Olav
|
by: Mortar |
last post by:
i need a datagrid with 2 header columns. The top one might have 1
column spanning 5 columns of the header row below it.
what is the best way to do this? Could i have 2 datatables...1 filling
the...
|
by: Dave |
last post by:
Hi, I'm trying to use templated columns to format the header for my datagrid.
Can I use the HeaderTemplate to make the "My Title Goes.." text to span
across the entire datagrid table when it's...
|
by: Mike Baugh |
last post by:
I am using visual studio 2005 to develop a form using c#
I have 3 datagrids on one form.
I can set the row color based on a certain value in a column. However this
color applies to all 3...
|
by: tshad |
last post by:
I have a datagrid that I cannot get to right justify a money amount (which
is just a label). No matter what I do - it still right justifies it.
<asp:TemplateColumn Visible="true"...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |