2014年7月13日 星期日

[RESOLVED] How to make a slanted or stepwise GridVeiw.


Hi,


I need to make a slanted or stepwise gridview as i am showing employee heirarchy in it. I am getting the details in every row only i need is to show every row a bit ahead of the above row.like this:


\


        \


              \


                   \


                       \


 



not able to use!!!!!



I dont want nested grid view i only need a simple slanted grid view...



I've 'indented' my first column by adding blank spaces( ) to the beginning of the text in the first column.  The number of spaces added were based on what level the row's data pertained to.  It would show something like this:


                     Customer Report

                               May 2013           June 2013

COUNTRY                5,555,555            5,555,555

    Region                   444,444               444,444

       State                     33,333                 33,333

         Store #1               2,222                   2,222

         Store #2               1,111                   1,111


 



Hi paindaasp I am using template field and taking data from from database so can u tell me where did u added spaces????


 


 



It is in the GridView's RowDataBound event.

But how to add space in .cs page.....what is the syntax m not getting it.


 


Thanks


 



This is a simple example in VB that checks to see if the third column has a 2 in it.  If it does, it indents the second column.  If you are using TemplateFields, you'll probably have to cast to a label(or whatever control is active in the column) and use
FindControl to manipulate the text.


Private Sub gridview1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles gridview1.RowDataBound
Dim indent As String = "     "
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.Cells(2).Text.ToString.Contains("2") Then
e.Row.Cells(1).Text = indent & e.Row.Cells(1).Text
End If
End If
End Sub


 


沒有留言:

張貼留言