PDA

View Full Version : seting textbox value(text) from a listbox


keithjakins
06-06-2005, 07:20 AM
Hi I am new to this so here goes
I can set the listbox items and values manualy as in the code below and everthing works as i expect. But if I set the listbox to use a dataset (no other changes ) the textbox does not change remains blank

Please help
Thanks



<%@ Page Language="vb" ContentType="text/html" ResponseEncoding="iso-8859-1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script runat="server">

Sub listbox1_SelectedIndexChanged(Sender as Object, E as EventArgs)

textbox1.Text = listbox1.SelectedValue
end sub
</script>
<html>
<head>

</head>




<form runat=server>

<asp:ListBox id=ListBox1 runat="server" Width="100px">
<asp:ListItem value="item1v">item1</asp:ListItem>
<asp:ListItem value="item2v">item2</asp:ListItem>
<asp:ListItem value="item3v">item3</asp:ListItem>
</asp:ListBox>




<asp:TextBox ID="TextBox1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Get Value" OnClick="listbox1_SelectedIndexChanged" />
</form>

</body>
</html>