Solved

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

Posted on 2014-09-30
5
147 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 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 500 total points
ID: 40353269
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
ID: 40353287
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 75

Expert Comment

by:käµfm³d 👽
ID: 40353290
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
ID: 40353310
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
ID: 40361909
right answer, but kaufmed made we think about rows when I was missing the point.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

791 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