I have a fairly simple page which queries a web service to pull data from a SQL server, returning a generic list of varying size. What I'm trying to do, is adjust the height of the div at runtime, adding a certain number of pixels to an existing CSS key on each iteration of a foreach loop, so that the projected list does not overflow the container div.
The code I am using to put the list on the page is as follows:
int total = 0;
lstUsageServices.Text = string.Empty;
lstUsageRequests.Text = string.Empty;
if (txtAccount.Text != string.Empty)
{
soapClient = new UsageService.ServiceSoapClient();
foreach (UsageClient.UsageService.Usage current in soapClient.GetUsage(txtAccount.Text, startPicker.SelectedDate, endPicker.SelectedDate))
{
lstUsageServices.Text += current.Service + "<br />";
lstUsageRequests.Text += current.Requests.ToString() + "<br />";
total += current.Requests;
}
lstUsageServices.Text += "<strong>Total</strong>";
lstUsageRequests.Text += "<strong>" + total.ToString() + "</strong>";
What I would like to do, is add a line inside the foreach to reference a div:
<div class="main" runat="server" id="mainDiv">
and increase the CSS "height:Xpx;" with each iteration.
I hope someone can help, it doesn't seem like this should be a difficult thing to do! Thanks in advance :)
div's height to increase as it gets more content, can't you just leave its height as automatic?