Link to home
Start Free TrialLog in
Avatar of sammySeltzer
sammySeltzerFlag for United States of America

asked on

How can I display header and records for each client?

Greetings again,

I am trying to take a different approach to solving this problem.

I have been stuck with it now for 3 days.

Here is what is going on.

I have an OnRowDataBound event showing below:

    Protected Sub clRowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim drv As DataRowView = e.Row.DataItem
            Dim nameid As String = drv("clientfirstname").ToString & Space(5) & drv("clientLastName").ToString & Space(5) & Space(5) & drv("clientID").ToString

        End If

    End Sub

Open in new window


Then on the markup page, the gridview has a datasourceId of SqlDataSource1 and this has both insert, delete and update commands.

When I run the code, it produces results similar to this:

             Code       Check       Check#      Cash

Edit Delete   403       $12.00                 $0.00  
Edit Delete   421       $0.00                  $0.00  
Edit Delete   430       $52.00       2344      $0.00  
Edit Delete   403       $0.00                  $0.00  
Edit Delete   402       $11.00                 $0.00 

Open in new window


It works in that I can update or delete any of the rows successfully.

The problem is that all client records are listed together.

We are trying to separate them by department. In other words, clients will be grouped based on the department their supervisor belongs to.


What I am struggling to do is to have header rows that separates the clients by their clientId such their the results looke more like this:

             Code       Check       Check#      Cash


Joe Bloe   1938383     Approve or Approved      Date of Approval
Edit Delete   403       $12.00                 $0.00  
Edit Delete   421       $0.00                  $0.00  
Edit Delete   430       $52.00       2344      $0.00  
Edit Delete   403       $0.00                  $0.00  
Edit Delete   402       $11.00                 $0.00 




Joe SixPack   1938384     Approve or Approved      Date of Approval
Edit Delete   405       $15.00                  $0.00  
Edit Delete   426       $10.00                  $0.00  
Edit Delete   437       $55.00       2344       $0.00  
Edit Delete   409       $110.00                 $0.00  
Edit Delete   400       $11.00                  $0.00 

Open in new window


Notice that each header starts with client's name, clientId, then a button that should show either the Approve text or Approved.

If tablename.ApprovalDate is blank or ApprovalDate is equal to the current year, then the text Approve should appear on the button.

When the supervisor clicks the Approve button, the database inserts date into the db and the text changes from Approve to Approved.

I can handle this. What I really need help on is the code for displaying all the records but separate each client's record based on clientID.

Can someone please help?

Thanks alot in advance
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Here is an example of grouping in gridview

http://www.codeproject.com/KB/webforms/GroupGridView.aspx
Hi,
For this you can use nested gridview. For first you can use the client name as datasource. Then for each client you can bind inner gridview with current results for a specific client.

For nested grid view check following article:
http://codeproject.com/KB/aspnet/MultiNestMDGridview.aspx
Avatar of sammySeltzer

ASKER

Hi guys,

Thanks alot for your responses.

CodeCruiser, always good to hear from you and thanks a lot for always jumping in to assist me whenver I come "knocking"

Here is the link to the one I prefer.

http://www.carlj.ca/2008/04/20/adding-or-inserting-subheader-rows-into-a-gridview/

I have actually integrated this one into my code just as the example showed.

I downloaded the full zipped code which was in c# and converted it to VB.

I have verified that I am using the code as indicated in the example.

Yet, I feel like something is missing because I can edit the first row of records but the rest are not accepting the values I enter when I attempted to edit.

I have had this problem before you might recall CodeCruiser.

I was able to solve it because that was for individual edits.

This is a little different because it groups so many different clients.

Please review the code in that link and I can send the version that I am using if you need it in order to help me make the necessary changes.

Whoever can help me resolve this is the biggest hero I have ever known because this has beaten me up for a long time.

THanks alot again guys.
BTW: ramkisan,

When I clicked on the link you provided, I get "Page Not Found"
ASKER CERTIFIED SOLUTION
Avatar of Ramkisan Jagtap
Ramkisan Jagtap
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.

Is it ok if I post my current build?

I really think it is very close to working.

If someone can take a look at it and compare it with the the link I sent to see what I could have missed or what I needed to add to make it edit ANY row successfully, not just the first row only.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, it goes into edit mode.

However, when you enter a value, the cursor automatically moves down to the next row.

Let's assume that there are 5 rows belonging to one client.

You click on Edit to edit the first row, enter your new value and click the Update button.

The new value is accepted as it replaces the new value.
It doesn't move down to the next row.

Now, you click on edit of the second row or any row for that matter, again it goes into edit more, you enter your new value and click the Update button.

This time, the cursor moves down to the next row without the new value.

If you disable this row as described in the link I posted:

tbl.Rows.AddAt(tbl.Rows.Count - 1, row)

Now, ALL rows begin to accept new values.

It is either that that code sample is not intended for editing or there is a bit missing.

I am so stuck on this that it is hard to explain the level of stress.
I have resolved this problem but I will award the points anyway.