Click here to Skip to main content
15,888,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a server side table in item template of gridview.
I am creating table rows and cells in grid Row DataBound event and adding it to that table.
The problem is that the table height is equal to height of td text. But i want table height to be equal to the height of cell of gridview.


Please help


Source
XML
<asp:TemplateField HeaderText="Load port">
                    <ItemTemplate>
                        <table runat="server" id="tblLoadPort" style="height:100%" >
                        </table>
                    </ItemTemplate>
                    <ItemStyle Width="150px" Height="100%"/>
                    <HeaderStyle VerticalAlign="Middle" HorizontalAlign="Left" Font-Size="Small" />
                </asp:TemplateField>



Code

HtmlTable tblLoadPort = (HtmlTable)e.Row.Cells[6].FindControl("tblLoadPort");
                
               System.Web.UI.HtmlControls.HtmlTableRow Tr = new HtmlTableRow();
                HtmlTableCell Tc = new HtmlTableCell();
                Tc.InnerText ="Some Text";
                if (CargoWiseDetails[e.Row.RowIndex].LoadPort_SOFStatus_Details != null & CargoWiseDetails[e.Row.RowIndex].LoadPort_SOFStatus_Details.Count > 0)
                {
                    Tc.Attributes.Add("class", PresentationUtils.FillLegend(CargoWiseDetails[e.Row.RowIndex].LoadPort_SOFStatus_Details[0].SOFStatus));
                }
                else
                {
                    Tc.Attributes.Add("class", "cssGray");
                }
                Tr.Cells.Add(Tc);                

                tblLoadPort.Rows.Add(Tr);
Posted
Comments
AkhileshPratap 15-Sep-11 3:53am    
Any suggestion...???
Herman<T>.Instance 15-Sep-11 7:50am    
maybe some css style is blocking you
Sunasara Imdadhusen 16-Sep-11 2:04am    
How many cell you are adding into table in Row DataBound Event?

Hi,

Try this line for your requirement.

HTML
<table width="100%" height="970" bgcolor="blue">

    </table>


If you mention percentages in height property it won't work in some browsers.

For better you can give pixel it can suits every browser


All the best.
 
Share this answer
 
only u can set width of %.
If u want to set height in 100%.
u need to find Client Computer resolution by java script and according to set weight of Table or div....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900