Hi,
This one appears a little strange to me. Here is the scenario.
I load a datalist the first time a page is run. The page has a !IsPostback
and the datalist gets loaded at this point.
I have a button on the page, where I want to read the contents of the
datalist. As an example that I have found on MS...
if (MyDataList.Items.Count > 0)
{
Response.Write("The Items collection contains: " + MyDataList.Items.Count +
"<br>");
foreach(DataListItem item in MyDataList.Items)
{
Response.Write(((Label)item.Controls[0]).Text + "<br>");
}
}
Now, here is the puzzling part.
The datalist reports 7 items in the items.count. This is absolutely correct,
BUT, I cannot read any of the items.
Initially, I was trying to read it as data from the datalist. As this was
not working, I have tried setting up a hidden label with the text. (I have
made the label visible to see what is happening)
Neither of them appear to contain anything, but the return count is 7 items.
The way I am doing it is practically the same way that MS are doing it...
http://msdn2.microsoft.com/en-us/sys...ist.items.aspx
The only difference is that the data in my itemTemplate of the datalist is
inside a label control. (Incidentally, I have also tried doing
item.FindControl("LabelName") to get something out)
Any help would be appreciated.
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available