tomo
tomo

Reputation: 23

DropDownList displaying System.Data.DataRow.View

I am using Visual Studio 2010 along with the Infragistics WebDropDown tool for ASP.NET (which is still new to me). I am using the 'drag-and-drop' approach along with the setup wizards for design and simplicity (although I prefer manual programming).

I have a Web User Control ("ClientSelect.ascx"). Into that form I added the necessary ScriptManager, and I also dropped in a WebDropDown tool. Using the WebDropDown Wizard, I established the WebDropDown's data source (which adds a connection to the database). The Wizard allows you to test the SQL query, and the results I got back are correct.

However, when the site loads, the values are "System.Data.DataRowView" instead of the actual value ("0001","0002" etc.). Is there anyway to "ToString()" these results. I'm just not seeing how my query returns the right results, but the WebDropDown outputs something else.

Here's my code:

    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    </asp:ScriptManagerProxy>

    <ig:WebDropDown ID="WebDropDown1" runat="server" Width="112px" 
     DataSourceID="SqlDataSource1" Height="20px">
    </ig:WebDropDown>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString5 %>" 
    SelectCommand="SELECT DISTINCT clientNum FROM myTable">
    </asp:SqlDataSource>

Thank you in advance for any advice.

ANSWER: I changed the query to "SELECT DISTINCT clientNum AS clients FROM myTable". I then added the attribute TextField = "clients". Thanks to MrZulu and ggonslav

Upvotes: 0

Views: 1965

Answers (2)

ggonsalv
ggonsalv

Reputation: 1262

You have to set the TextField property to clientNum .

Here is the link

Infragristics Help Step 15

<ig:WebDropDown ID="WebDropDown1" runat="server" Width="112px"   
DataSourceID="SqlDataSource1" Height="20px"
 TextField ="clientNum" >  
</ig:WebDropDown>

Upvotes: 0

MrZulu
MrZulu

Reputation: 109

place DataTextField="clientNum" as an attribute <ig:WebDropDown ...>

Upvotes: 2

Related Questions