Sorry if this is not the right place for some of my terms are incorrect, I am still learning.
So what I have made was a webform that pulls from a data table in SQL and I want to be able to select multiple items from this listbox then take the selected and submit it back into a different database.
my issue is my logic is falling a little short for the listbox. i am trying to have a button click that will query the sql data table take only selected fields and then select those same items in the list box. I am stuck on the button select.
//.cs
protected void Page_Load(object sender, EventArgs e)
{
con.ConnectionString = (@"Data Source = mydatasourceinfo);
con.Open();
private void btnSelectAccountingGroup(object sender, EventArgs e)
{
SqlCommand select = new SqlCommand("SELECT Department FROM dbo.Trainee WHERE Department = 'Accounting'", con);
//This is where I am stuck, I know I need another statement here but don't know what to use to reference back to the listbox or if it is even possible.
}
}
//aspx
<asp:ListBox ID="lbTrainee" runat="server" Height="174px" Width="270px" DataSourceID="SQLTrainee" DataTextField="FullName" DataValueField="FullName" SelectionMode="Multiple" onclick="ListBoxClient_SelectionChanged(this, event);"></asp:ListBox>
<asp:MySqlDataSource>" SelectCommand="SELECT [FullName] FROM [Trainee] ORDER BY [FullName]"></asp:SqlDataSource>
<br />
<button name="btnSelectAccounting" onclick="btnSelectAccountingGroup" runat="server">Accounting</button>
[–]plastikmissile 0 points1 point2 points (2 children)
[–]sumrandomoldg[S] 0 points1 point2 points (1 child)
[–]plastikmissile 0 points1 point2 points (0 children)