Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Merge /Split cell in GridView 2

Status
Not open for further replies.

shmilyca

Programmer
Apr 30, 2006
63
US
Hi,
How to merge/split cell in a grid view? In other words ..how to use rowspan/colspan in gridview

Thank you

BB
 
hmm. not possible directly, why would u want to do that? the only way i see is to use the ItemDataBound event to change the attribtes of the cells that need to be merged...

Known is handfull, Unknown is worldfull
 
Well..I am showing image in one of column i want split same column into two to show title of image.
 
A gridview may not be the best solution then as it renders a table which isn't really for displaying images. Try using a repeater instead as you'll have a lot more control over the output.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ty..never used it before...In gridview I could create image succesfully though. Im just trying Image cell into two ..so top part I can show heading and 2nd part I can show Image..Here is code

<asp:ImageField DataImageUrlField="sPathImage1" >
<ItemStyle Height="50px" Width="50px" />
<ControlStyle Height="50px" Width="50px" />
</asp:ImageField>
 
Yes, you are right that it is possible but I don't think it's the best option. Instead, use a repeater and use CSS to position your images accordingly.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I am sorry I am new to VWD2005.
This is example page what I am trying to do..

<html>
<head>
</head>
<body>
<table border = 1>
<tr>
<td width = 5%>row 1,1 Heading</td>
<td width = 15% rowspan = 2>row 1,col 2</td>
<td rowspan = 2>notes:row 1 col3</td>
</tr>
<tr>
<td width = 5%>row 1,2 pic here</td>
<tr>
<td width = 5%>row 2,1 Heading</td>
<td width = 15% rowspan = 2>row 2,col 2</td>
<td rowspan = 2>notes:row 2 col3</td>
</tr>
<tr>
<td width = 5%>row 2,2 pic here</td>

</tr>
</table>
</body>
</html>

Here To have split effect in first colunm .. I have to merge two rows for rest of the columns. How can I have two rows for one item in repeater ?
 
Not sure..may be this is dumb...

Isnt there any way I can stick panel in first cell,stick image in panel and just change caption of panel?
 
only the heading is required as split right? then dont include it in the repeater. can i have ur repeater code???

Known is handfull, Unknown is worldfull
 
sure..Please ignore column "Img". Imamge path is stored in field sPathImage1. I need to add title to column Img2 which is stored in field sImageTitle. (Right now its not there in query because I dont know how to add title)


<%@ Page Language="VB" %>
<%@ Register Assembly="BetterImageProcessor" Namespace="BetterImageProcessor" TagPrefix="BIP" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<script runat="server">

</script>

<html xmlns=" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="AccessDataSource1">
<HeaderTemplate>
<table border=1>
<tr>
<td>ID</td>
<td>Description</td>
<td>UOM</td>
<td>Img</td>
<td>Img2</td>
</tr>
</HeaderTemplate>
<ItemTemplate>

<tr>
<td> <%# DataBinder.Eval(Container.DataItem, "ID") %> </td>
<td> <%# DataBinder.Eval(Container.DataItem, "sDesciption") %> </td>
<td> <%# DataBinder.Eval(Container.DataItem, "sUOM") %> </td>
<td> <%# DataBinder.Eval(Container.DataItem, "sPathImage1") %> </td>
<td class="imgspace">
<img src=<%# DataBinder.Eval(Container.DataItem, "sPathImage1") %> width="50px" height="50px" class="bigtext">
</td>
<td>
<asp:TemplateField HeaderText="Thumb">
<ItemTemplate>
<BIP:BetterImageLink ID="BetterImageLink1" runat="server"
ToolTip="Click to enlarge" ThumbWidth="100" ThumbHeight="100" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "sPathImage1") %>'

TARGET="_self" AutoCenter="true" BorderStyle ="none" WindowTitle ="test"
BorderWidth ="0"
/>
</ItemTemplate>
</asp:TemplateField>
</td>
</tr>

</ItemTemplate>

</asp:Repeater>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/TestMast.mdb"
SelectCommand="SELECT ID, sDesciption, sUOM, sPathImage1 FROM P_Master Order by ID"></asp:AccessDataSource>
</form>
</body>
</html>
 
and which one must have the colspan? the header or the item???

Known is handfull, Unknown is worldfull
 
try:
<td colspan=2>Img2</td>


Known is handfull, Unknown is worldfull
 
Thank you very much..Appriciated..It did the trick but I dont have control over position of title though.
 
yes u do:
<td colspan=2 align=center>Img2</td>


Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top