I wrote this code and it gives me only the last element of the column in a list. How can I get all elements in the TextBox?
SPListItemCollection items = list.GetItems(myquery);
foreach (SPListItem item in items)
{
if (item["Title"] != null)
{
TextBox1.Text = (string)item["Title"];
}
}
You are overwriting the text within the text box at each iteration, so you only see the last value… Try this: