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
LVL 29
sammySeltzerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CodeCruiserCommented:
Here is an example of grouping in gridview

http://www.codeproject.com/KB/webforms/GroupGridView.aspx
0
Ramkisan JagtapLead DeveloperCommented:
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
0
sammySeltzerAuthor Commented:
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.
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

sammySeltzerAuthor Commented:
BTW: ramkisan,

When I clicked on the link you provided, I get "Page Not Found"
0
Ramkisan JagtapLead DeveloperCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sammySeltzerAuthor Commented:
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.
0
CodeCruiserCommented:
Sammy,
Glad I am of help.

> I can edit the first row of records but the rest are not accepting the values I enter when I attempted to edit.

Can you describe what happens? Does it not go into edit mode or does it not accept the new values?
0
sammySeltzerAuthor Commented:
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.
0
sammySeltzerAuthor Commented:
I have resolved this problem but I will award the points anyway.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.