Hello All,
I just wanted to know if there is any way to dynamically set the width of a column inside a table within a datalist based on the length of the text fetched from the database.I am inserting my code.In the code below I want the width of collapsible panel to be dynamically set based on the length of the address and interest fields.Please give some suggestions.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="knzpersonnel.aspx.cs" Inherits="personnel_knzpersonnel" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager_CollapsiblePanel" runat="server">
</asp:ToolkitScriptManager>
<aspatalist ID="Datalist_PersonnelData" runat="server" Width="60%">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="1600">
<tr>
<td width="400">Full Name</td>
<td width="400">Phone</td>
<td width="400">Email</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="1600">
<tr>
<td width="400">
<aspanel ID="Panel2" runat="server">
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/plus.jpg" ></asp:Image>
<%#Eval("Full Name").ToString()%>
</aspanel>
</td>
<td width="400">
<%#Eval("Phone").ToString()%>
</td>
<td width="400">
<%#Eval("Email").ToString()%>
</td>
</tr>
<br />
<tr>
//I want to set this width dynamically based on the length of text fetched from the database
<td>
<aspanel ID="Panel1" runat="server" BorderStyle= "Outset">
<strong>Address:</strong>
<asp:Label ID="Label_Address" runat="server" Text='<%#Eval("Address").ToString()%>'></asp:Label>
<br />
<strong>Interests:</strong>
<asp:Label ID="Label_Interests" runat="server" Text='<%#Eval("Interests").ToString()%>'></asp:Label>
<br />
<asp:HyperLink ID="HyperLink_FullDetails" runat="server" Text="Full Details" NavigateUrl=" </aspanel>
<asp:CollapsiblePanelExtender ID="CollapsibleControl_Name" ExpandControlID="Panel2" runat="server" ImageControlID="Image1" ExpandedImage="~/images/minus.jpg" CollapsedImage="~/images/plus.jpg" ExpandDirection="Vertical" CollapseControlID="Panel2" Collapsed="true" EnableViewState="false" TargetControlID="Panel1"></asp:CollapsiblePanelExtender>
</td>
</tr>
</table>
<br />
<br />
</ItemTemplate>
</aspatalist>
</form>
</body>
</html>
I just wanted to know if there is any way to dynamically set the width of a column inside a table within a datalist based on the length of the text fetched from the database.I am inserting my code.In the code below I want the width of collapsible panel to be dynamically set based on the length of the address and interest fields.Please give some suggestions.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="knzpersonnel.aspx.cs" Inherits="personnel_knzpersonnel" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager_CollapsiblePanel" runat="server">
</asp:ToolkitScriptManager>
<aspatalist ID="Datalist_PersonnelData" runat="server" Width="60%">
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="1600">
<tr>
<td width="400">Full Name</td>
<td width="400">Phone</td>
<td width="400">Email</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="1600">
<tr>
<td width="400">
<aspanel ID="Panel2" runat="server">
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/plus.jpg" ></asp:Image>
<%#Eval("Full Name").ToString()%>
</aspanel>
</td>
<td width="400">
<%#Eval("Phone").ToString()%>
</td>
<td width="400">
<%#Eval("Email").ToString()%>
</td>
</tr>
<br />
<tr>
//I want to set this width dynamically based on the length of text fetched from the database
<td>
<aspanel ID="Panel1" runat="server" BorderStyle= "Outset">
<strong>Address:</strong>
<asp:Label ID="Label_Address" runat="server" Text='<%#Eval("Address").ToString()%>'></asp:Label>
<br />
<strong>Interests:</strong>
<asp:Label ID="Label_Interests" runat="server" Text='<%#Eval("Interests").ToString()%>'></asp:Label>
<br />
<asp:HyperLink ID="HyperLink_FullDetails" runat="server" Text="Full Details" NavigateUrl=" </aspanel>
<asp:CollapsiblePanelExtender ID="CollapsibleControl_Name" ExpandControlID="Panel2" runat="server" ImageControlID="Image1" ExpandedImage="~/images/minus.jpg" CollapsedImage="~/images/plus.jpg" ExpandDirection="Vertical" CollapseControlID="Panel2" Collapsed="true" EnableViewState="false" TargetControlID="Panel1"></asp:CollapsiblePanelExtender>
</td>
</tr>
</table>
<br />
<br />
</ItemTemplate>
</aspatalist>
</form>
</body>
</html>