How to swap gridview header and column from ltr to rtl

Posted by Skaftabali under ASP.NET on 10/27/2010 | Points: 10 | Views : 3979 | Status : [Member] | Replies : 2
Hi there,

I have a grid which displays a Course Code, Course Name ,Lavel Code and possible products within the subcategory.
Now when i display the products I display my gridview containing these columns,



This is Ltr for English language

Course Code Course Name Group Type Lavel Code

IC 101 Intro. to Islamic Culture 1 1
IC 101 Intro. to Islamic Culture 1 1
IC 101 Intro. to Islamic Culture 1 1


Now what my requirement is that i would like to Click Arabic button from the form.
At that time my gridview will be change direction like that

Lavel Code Group Type Course Name Course Code
1 1 Intro. to Islamic Culture IC 101



Is there any way of doing this in a grid view control? If not can anyone provide me the sample code to do this.
Its very urgent i tired two and three day but i didn't get.pls reply as soon.




Responses

Posted by: Raja on: 10/27/2010 [Member] Starter | Points: 25

Up
0
Down
Try below approach, hopefully this will give you some clue.

Approach 1: - Server side
1. When you are clicking on Arabic button, fire a server side event.
2. Create a GridView on the fly.
3. Iterate through the current GridView and add each column one by one into the dynamically created gridview in the reverse order.
4. Add the dynamically generated GridView into the asp:panel in the aspx page.

Approach 2: Client side
1. User jQuery to find the columns of the GridView columns, there are many code snippets available on this website as well as google on how to find the cell of the gridview.
2. Maintain the number from left for each cell.
3. Dynamically generate the html table on the fly using jQuery or JavaScript
4. Add the generated code in the div.

Hope this will give some clue.

Thanks

Regards,
Raja, USA

Skaftabali, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 10/28/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Just give the following Code in your button event what you need ?
I think its your requirement.


// Your Requirement
For Right to Left
GridView1.Style[ HtmlTextWriterStyle.Direction] = "rtl"; //Totally change the direction from Right to Left in DataGridView including Header.

For Left to Right
GridView1.Style[ HtmlTextWriterStyle.Direction] = "ltr"; //Totally change the direction from Left to Right in DataGridView including Header.


Cheers :)

Thanks,
T.Saravanan

Skaftabali, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response