Home/ASP.NET Forums/General ASP.NET/Web Forms Data Controls/loop through gridview

loop through gridview [Answered]RSS

8 replies

Last post Sep 16, 2010 12:10 PM by Nivash

Remember to click “Mark as Answer” on the post, if it helps you. Because It helps others to find the solution
  • Qin Dian Tang - MSFT

    Qin Dian Tan...

    All-Star

    113550 Points

    12480 Posts

    Microsoft

    Re: loop through gridview

    Sep 15, 2010 04:25 AM|Qin Dian Tang - MSFT|LINK

    Hi Nivash,

    I think it is not the problem of GridView. It is the problem of objV object. What does method "objV.SelectLineDates" do? You cannot get the values from the properties in objV such as "propQuoteLineID" and others in loop. Please check the objV Object to see whether these properties can be set correctly. I guess they are not assigned values.

    If you want to show master/detail values, you can get them directly from GridView, not from the data source. You can loop the parent GridView to get each quote, then in the loop to do another loop for child GridView to get each product for that quote.

    Thanks,

    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
    Microsoft One Code Framework
  • Nivash

    Nivash

    Participant

    1542 Points

    409 Posts

    Re: loop through gridview

    Sep 15, 2010 08:06 AM|Nivash|LINK

    Hi Qin Dian Tang

    The objV.SelectLineDates method is stated below, I have another method that sends the ID's to the gridview, then I want to take these ID's and run them against 2 querys,  I am just using the datagrid to hold the ID's of the quote_header, I want to loop through each ID and display The Quote_Header information and below that the line information, then again the quote header information and the the quote line information, I just want to write this out on the screen for now, Later on I will use and accordion where the Quote_Header information will be displayed and when the user clicks then the line items will display for that Quote Header. If i run the stored procedure in sql in the below code it works fine

    Public Function SelectLineDates(ByVal _qref As Integer) As List(Of ValidateQuote)
            Dim objdal As New csSQLDALVB
            Dim objlist As New List(Of ValidateQuote)
            Dim dr As System.Data.IDataReader
            Dim objparlist As New List(Of csParameterListType)
    
    
            objparlist.Add(New csParameterListType("@qref", SqlDbType.Int, _qref.ToString()))
    
    
            dr = objdal.executespreturndr("sp_get_quote_line", objparlist)
    
    
            Using dr
                While dr.Read
                    Dim objpb As New ValidateQuote
                    Populate_data3(dr, objpb)
                    objlist.Add(objpb)
                End While
            End Using
            Return objlist
        End Function
    
    
        Private Sub Populate_data3(ByVal objread As System.Data.IDataReader, ByVal objt As ValidateQuote)
            'just display the ID in the UI to test if this is working, then add the rest of the properties to display
            objt.propQuoteLineID = objread.GetInt32(0)
        End Sub


     

     

    Remember to click “Mark as Answer” on the post, if it helps you. Because It helps others to find the solution
  • Qin Dian Tang - MSFT

    Qin Dian Tan...

    All-Star

    113550 Points

    12480 Posts

    Microsoft

    Re: loop through gridview

    Sep 16, 2010 02:51 AM|Qin Dian Tang - MSFT|LINK

    Hi Nivash,

    It is hard for me to find out where is wrong in your case. If the following lines don't work:

    objV.SelectLineDates(row.Cells(0).Text)   
    Response.Write(objV.propQuoteLineID & "---")   
    Response.Write(objV.propProdName & "---")   
    Response.Write(objV.propQty & "---")   
    Response.Write(objV.propLineTotal & "---")

    The only reason is that in the object class "objV" you don't assign values to these properties "propQuoteLineID", ...
    If the values are assigned to them correctly, it surely outputs on screen. You need to set the breakpoint at the code where you assign these values in object class to see what happens there.

    Thanks,

    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
    Microsoft One Code Framework
  • Nivash

    Nivash

    Participant

    1542 Points

    409 Posts

    Re: loop through gridview

    Sep 16, 2010 12:10 PM|Nivash|LINK

    Hi Qin Dian Tang

    These 2 articles helped me fix my problem.

    http://mosesofegypt.net/post/Building-a-grouping-Grid-with-GridView-and-ASPNET-AJAX-toolkit-CollapsiblePanel.aspx

    http://www.gadhiasiraj.com/Dev3P5/GridView/GV_1toN.aspx

    Thanks for your help everybody!

     

    Remember to click “Mark as Answer” on the post, if it helps you. Because It helps others to find the solution
  • ‹ Previous Thread|Next Thread ›