Solved

why am I getting System.Data.DataRowView as answer?

Posted on 2014-09-30
5
140 Views
Last Modified: 2014-10-05
have this gridview which has dropdownlists
 <asp:gridview id="CustomersGridView"  
       autogeneratecolumns="false"
        autogenerateeditbutton="true"  
        onrowdatabound="CustomersGridView_RowDataBound"
        onrowediting="CustomersGridView_RowEditing"  
        onRowCancelingEdit="Customer_RowCancelingEdit"
        onRowUpdating="Customers_RowUpdating"
       
        runat="server">  
        <columns>
         
            <asp:boundfield datafield="WORKDATE"
            readonly="true"      
            headertext="DAY"/>
            <asp:boundfield datafield="STARTDAY"
            readonly="true"      
            headertext="DAY"/>
           
           <asp:TemplateField HeaderText="IN">
           <ItemTemplate>
             <asp:DropDownList ID="DropDownList1" runat="server"  >              
                 </asp:DropDownList>        
          </ItemTemplate>
             </asp:TemplateField>

in the onrowUpdatating function I have this to fill the dropdownlist1
If e.Row.RowType = DataControlRowType.DataRow Then
            Try
                sqlfindhrsfill = "Select JobCode from testday "
                Using adapter7 As SqlDataAdapter = New SqlDataAdapter(sqlfindhrsfill, Connection)
                    Connection.Open()
                    adapter7.Fill(Dst, "Dsthrslist")
                    Connection.Close()
                    Dim ddl = DirectCast(e.Row.FindControl("DropDownlist1"), DropDownList)
                    ddl.DataSource = Dst.Tables("DsthrsList")
                    ddl.DataBind()
                End Using
            Catch
            End Try
        End If
the sql table has a series of numbers: 0:00, 0:15 0:30 which amounts to a 24hr clock.  There are 97 entries
what I get on the dropdownlist is the line System.Data.DataRowView  97 times.

any suggestions

gary
0
Comment
Question by:javagair
  • 3
  • 2
5 Comments
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 500 total points
Comment Utility
Not 100% on this, but try changing this line:

ddl.DataSource = Dst.Tables("DsthrsList")

...to this:

ddl.DataSource = Dst.Tables("DsthrsList").Rows

Open in new window

0
 

Author Comment

by:javagair
Comment Utility
tried it, sadly no.
I am thinking that to call rows one would have to fill each row with code.  I think I read someplace that the ddl knows how to fill from a table, could be wrong!  Probably a simple answer that is just alluding me.
usually use a coded list, first attempt at filling with table.

thanks

gary
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
If no one pops in with the correct answer sooner, I'll throw together a throw-away project at home and provide you with the correct approach.
0
 

Accepted Solution

by:
javagair earned 0 total points
Comment Utility
the answer is:
didn't tell it what field in table to put.
   ddl.DataTextField = "Jobcode"
                    ddl.DataValueField = "JobCode"

Started at that code for an hour and didn't catch that two lines are missing, even though I put them in html code when needed.

thanks for the offer

gary
0
 

Author Closing Comment

by:javagair
Comment Utility
right answer, but kaufmed made we think about rows when I was missing the point.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now