Click here to Skip to main content
15,891,981 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there! I have a page built in asp.net using c# as codebehind with 2 table. 1 for PESO currency and the other is for DOLLAR.

I want to apply the TR height of tblPESO to tblDOLLAR using c#? how is this possible?

ASP.NET
<table id="tblPESO"   runat="server">
<table><tr id="trBank">
<td>
//I have a gridview here
</td></tr></table>


<table id="tblDOLLAR"   runat="server">
<table><tr id="trBankD">
<td>
    //gridview for dollar
</td>
</tr>
</table>



C#
public void setTRHeight()
{
   trBankD.Height = trBank.Height;
}


Thanks for your help!

What I have tried:

I tried getting the id of tr of tblPESO and apply to tr of tblDOLLAR, but cant get the height.
Posted
Updated 1-Mar-16 20:08pm
v3
Comments
F-ES Sitecore 2-Mar-16 7:08am    
Your elements only gain a height when they are rendered in the browser so you can't get this data in your code-behind as the browser only gets your html after the code-behind has finished. You'll need to do this using javascript. Google something like "javascript match table size" or "javascript get tr height" and "javascript set tr height" and you'll probably find examples on how to do this.

1 solution

Hi,

You can refer the following link where it is clearly mentioned how you can use the height property for a table to its row from code behind.

Row height from code behind

Thanks,
Sisir Patro
 
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