Hi,
After some help and reviewing of the code I got this working without any errors. However when I push the button nothing happens, the text-box ain't updated.
I also wounder how i can access the data inside the DataList so that I can manipulate it inside the "DataList1_ItemCommand" function.
<p>
<asp:TextBox ID="NameTextBox" runat="server" CssClass="textEntry"
TextMode="SingleLine" Rows="0" Height="20px" Width="250px" Enabled="False"></asp:TextBox>
<asp:DataList
ID="DataList1"
runat="server"
RepeatColumns="1" CellPadding="4" ForeColor="#333333"
GridLines="Both" Height="132px" Width="427px">
<HeaderTemplate>
Data
</HeaderTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "ref") %>
<%# DataBinder.Eval(Container.DataItem, "name") %>
<%# DataBinder.Eval(Container.DataItem, "city") %>
<%# DataBinder.Eval(Container.DataItem, "ip") %>
<%# DataBinder.Eval(Container.DataItem, "timestamp") %>
<asp:Button ID="manage" runat="server" CommandName="manageWiki" Text="Granska" Visible="True" />
</ItemTemplate>
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Bold="true" Font-Names="Arial" BackColor="#5D7B9D"
ForeColor="White" />
<ItemStyle Font-Names="Arial" Font-Size="Small" BackColor="#F7F6F3"
ForeColor="#333333" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:DataList>
</p>
And code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//getSuggestions fill the DataList with data
getSuggestions("SELECT [ref], [city], [name], [timestamp], [ip] FROM [table1] ORDER BY timestamp");
}
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "manageWiki")
{
//Just update the TextBox
NameTextBox.Text = "ref that is inside the Datalist1";
}
}