J
Julius Mong
Hi dear experts,
I'm new to ASP.NET and am having a hard time trying to make this work I
have a ddl which contains 2 or more items (populated by code) and a submit
asp:button that I'd want when clicked simply sends the ddl's selected item's
text value to an asp:label. I have searched through google for a couple of
days and have tried many things like setting autopostback on the ddl but
nothing is working I simply can't work my head round this...
I now have :
<form id="Form1" method="post" runat="server">
<P>
<table cellSpacing="10" cellPadding="0" width="880" border="0">
<tr>
<td id="content_0">
<P><asp:dropdownlist id="lstServer" runat="server"
Width="168px"></asp:dropdownlist> </P>
<P><asp:button id="btnSubmit" runat="server"
Text="Submit"></asp:button>
<P><asp:label id="lblStatus" runat="server">Server Status
:</asp:label> </P>
</td>
</tr>
</table>
</P>
</form>
and in the aspx.cs I have the method registered to the click event:
private void btnSubmit_Click(object sender, System.EventArgs e)
{
lblStatus.Text = lstServer.SelectedItem.Text ;
}
However it is always showing the first item in the ddl... I have tried
putting a public string in teh webform class and on the ddl's
selectedindexchange store that selectedvalue to the public string and
retrieve it when Page.IsPostBack on Page_Load and have btnSubmit_Click get
the string instead, but it is always the first item int he ddl still... I am
so confused... could someone kindly point me int he right direction
please... or let me know where on the Web I should look...
Thanks tonnes!!!
Jules
I'm new to ASP.NET and am having a hard time trying to make this work I
have a ddl which contains 2 or more items (populated by code) and a submit
asp:button that I'd want when clicked simply sends the ddl's selected item's
text value to an asp:label. I have searched through google for a couple of
days and have tried many things like setting autopostback on the ddl but
nothing is working I simply can't work my head round this...
I now have :
<form id="Form1" method="post" runat="server">
<P>
<table cellSpacing="10" cellPadding="0" width="880" border="0">
<tr>
<td id="content_0">
<P><asp:dropdownlist id="lstServer" runat="server"
Width="168px"></asp:dropdownlist> </P>
<P><asp:button id="btnSubmit" runat="server"
Text="Submit"></asp:button>
<P><asp:label id="lblStatus" runat="server">Server Status
:</asp:label> </P>
</td>
</tr>
</table>
</P>
</form>
and in the aspx.cs I have the method registered to the click event:
private void btnSubmit_Click(object sender, System.EventArgs e)
{
lblStatus.Text = lstServer.SelectedItem.Text ;
}
However it is always showing the first item in the ddl... I have tried
putting a public string in teh webform class and on the ddl's
selectedindexchange store that selectedvalue to the public string and
retrieve it when Page.IsPostBack on Page_Load and have btnSubmit_Click get
the string instead, but it is always the first item int he ddl still... I am
so confused... could someone kindly point me int he right direction
please... or let me know where on the Web I should look...
Thanks tonnes!!!
Jules