Okay, so I’ve got the follwing mark up:
Here I have a listbox that is to be populated by some SQL query.
<asp:ListBox ID="MyListBox" runat="server"
DataSourceID="MyDataSource" DataTextField="Field1" DataValueField="ID" ></asp:ListBox>
<asp:SqlDataSource ID="MyDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
SelectCommand="SELECT [ID], [Field1] FROM [Table1] WHERE ([ID2] = @ID2)">
<SelectParameters>
<asp:SessionParameter Name="ID2"
SessionField="ID2" DbType="Guid"/>
</SelectParameters>
</asp:SqlDataSource>
A few problems that I have:
The list box always is empty and when I try and test the query, it always presents a dialogue box asking for me to input “Type” “DbType” and “Value”. I’m not too sure what to pick here.
I’ve tried running the application, ensuring that there is the needed session data in the correct key. (Session["ID2"] has been given a Guid). However, when I get to the listbox, it’s empty even though I can look at the table data and know what should be there.
I have solved this issue. Basically, I assumed that the query should return results when it rightly shouldn’t have done. Additionally, the data in
Field1was an empty string. So when it did return results, I wouldn’t see anything in the ListBox.