How can I reset the style of GridView from client-side....????


I've already changed the style this way:

1     protected void dgViewSelectedItems_RowDataBound(object sender, GridViewRowEventArgs e)
2     {
3        if (e.Row.RowIndex > -1)
4        {
5           e.Row.Attributes.Add("onclick", "return rowClick(this," + e.Row.RowIndex + ")");                
6        }            
7     }
9     protected override void Render(HtmlTextWriter writer)
10    {
11        string script = @"function rowClick(row, rowIndx)                                
12                          {   
13                              document.getElementById(""" + this.ClientID + "_" + this.txtHRowIndex.ID + @""").value = rowIndx;                                    
14                     = ""bold""; 
15                     = ""Silver"";                           
16                              // = ""hand"";
17                          }
18                                ";
20        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "HrDocTemplate", script,true);
21        base.Render(writer);
22    }

txtHRowIndex this is a hidded text box where I set the row Index when a row is clicked. Usign it i've done some task.

However the task of this function is to set the color of the row item to Silver and make the font Bold. It's working fine.

Now when I select another row the previous selected row item's font style should be restored? How can I do that?

Note: I'm not writing inline code. So, whatever I do, I've to do in the code behind using Render. 


mark as answer if my response is fruitful for u
8/6/2007 9:54:30 AM 72751 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 59


Do you want to change the selected row's forecolor and font after you select the row? When you select another row, you hope to keep the style of the row selected previously. Right?

If you use javascript to achieve this, the changes will be lost when the page is post back.

So you are suggested to achieve this by the code in server-side.

You can add an SelectedIndexChanged event handler where you should apply new style to the row.

Here is an example.

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        if (GridView1.SelectedRow != null)
            Style style = new Style();
            style.ForeColor = System.Drawing.Color.Red;
            style.Font.Bold = true;

 The style will be preserved even if the page is post back.

Hope it helps.

Techie Zhang
Microsoft Online Community Support
8/8/2007 8:36:10 AM



mark as answer if my response is fruitful for u
8/13/2007 7:55:29 AM

Similar Artilces:

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in ( required field, range validator and others) question is the required field validator is a server side control. So does that mean that it does a post back? it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

Can we access controls within user controls on the client side without using ctl0_ControlsName
When we create controls within our user controls, the way we can access those controls in client side is i guess:getElementByID('the client id')but the server chnages the names of those controls to:  clt0_Controlsname, so i always have to use add ctl0 when I want to access to my controls of the user control on the client there a solution to this or that s just the way it isthank you Thanks a lot, I appreciate your taking the time to help me. Hello tutus,this is maybe the most frequent question in this forum, did you notice?This problems is related to all server co...

What are diff Server-side control and Client-side control ?
What are diff Server-side control and Client-side control ? and diff server -side coding and client -side coding ? please help I have answered the first part of your question in your previous posting. Server-side coding languages are ASP, ASP.NET, PHP, CGI (Perl) and many, many more. They are used to create dynamic web content (based on additional information that is attached to the request) and are often used to extract information from databases. Client-side coding languages are JavaScript, VBScript, EMACScript and are used to create dynamic content that responds to the u...

Combining a server-side control with a client-side control!
Hi all, I am trying to combine a server-side control with a client-side control. I have created a listbox in both sides, the client-side control's code is: <select size="4" name="lstFruit" id="Select1" ondblclick="lst_dblClick" visible="false"> <option value="Banana">Banana</option> <option value="Apple">Apple</option> <option value="Mango">Mango</option> <option value="Orange">Orange</option> </select> The other one is the server-side control which has this code:   I wanted to add the ondblClick attribute to the se...

List of client side function of extenders and controls for client side
Hello All,I am using AJAX control toolkit for my current project. Now I need to find out what client side functions I can call on an extender. Lets say I am using a PopControlExtender. Now I want to show the popup from a JS funtions.If I can do a guess then it would be something like this$find('ppce').show();From where I can find what client side functions I can call on those extensders. This is really a frusterating thing. I learn about extenders only from Learn tutorials, no help here and there. Can anybody please tell me where are documentations about all the extenders in the tool...

accessing controls of a gridview on client side
Can anyone help me?   I have 3 dropdowns in ItemTemplates of a gridview if I change any value in one of thes dropdowns I have to multiply all the 3 dropdown values and I have to place that value in a label of a gridview. I want to do that on Clientside. on row databound event of gridview I have added attributes to all the dropdowns like DropDownList ddl; ddl = (DropDownList)e.Row.FindControl("ddlQ1"); ddl.Attributes.Add("OnChange", "CalculateBPScore();");  In javascript how can I access these dropdowns and label Thanks Accessing Grid...

How do you reset Validation controls on the client side
I have a web page that uses Validation Controls to check the input from a user. I use javascript to hide and unhide a panel that houses the form. I would like to be able to reset the validation  with javascript on the client side if the user closes the panel. I would have a function that sets the validation variables and controls to default values and call it when the panel is closed.  Or use a hidden button to call the causesvalidation property to false and fire it.  Post a code example so we can see what you are trying to do. Remember to mark any post that i...

Is there a correspondance for each server side control to be equivalent to a client side html control
Where can find the list and can use that equivalence and what is its usage plsThanksThanks a lot, I appreciate your taking the time to help me. What exactly do you mean? A correspondence of what?All controls have a ClientID property, which for most controls tells the DOM element ID that will be used in the HTML rendering. Aside from that certain controls might offer additional client-side functionality, but there's no one standard.Thanks,EilonBlog: I mean. When I am using html control in my aspx page like:  <input type=text ..>  and...

Hi guys, two gridviews, same page, but one cant define paramters, the other one can.  the one that works is the first example, the one that doesnt work is the second example.  what is the difference? if you could highlight why example two doesnt detect contorls that would be great!!! example one <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2&qu...

Can i update dynamicly my any control in client side?
 i using update panel but it working very slowly. i need change a label.text property when i changed Drop Down List selected item. if Drop Down List and Label in same updatepanel, Drop Down List's autopostback property true and updatepanel update method is conditional, it works slow.  asp codes;<asp:UpdatePanel ID="UpdatePanel7" runat="server" UpdateMode="Conditional"> <ContentTemplate> <table cellpadding="0" cellspacing="...

How to access dynamically Html controls (client side controls) using C# server side scripts
Folks,I have problem try to to access dynamically Html controls (client side controls) using C# server side scripts. Please give me helps.     The error is as follows Exception Details: System.InvalidCastException: Specified cast is not valid.Source Error: Line 79: { Line 80: Control c = Page.FindControl("ddlTC" + i); Line 81: ((DropDownList)c).DataSource = mdt; Line 82: ((DropDownList)c).DataTextField = "ClassID"; Line 83: ((DropDownList)c).DataValueField = "Course"; My aspx page source codes: ...<...

can we populate the datagrid web control on client side.
Hi, I would like to know if there is a way to populate the datagrid web control on client side. Can this be done some how using client side javascript and xml etc.? Any third party grid control available for the same ? Regards, Ashwini Do you mean that files will be stored at the client-side and you want to show it in the databound control - then i doubt it, javascript functionality is usually very restricted at the client. You might need to upload the files to the server first If in contast you are looking at downloading the data to the client then showing it bit by bit,...

How can I capture the values of a CheckBoxList control on the client side
I need to capture all the values of the checked check boxes generated from a CheckBoxList in client-side javascript code. The only problem is that the check boxes generated all seem to have different id's and no value attribute. Does anyone have any quick suggestions, or am I back to generating the checkboxes with traditional asp style code....

How can I send data to database in a client side control?
I am using a normal HTML button < button onclick="Confirm()" >   to control a popup window. I use the button to send the data from the form to database and close the popup window. The javascript function Confirm() does the close window action. The question is, because I am not using a server side control like , how can I send the data, on the popup window to the server to store in database? Do I need to use Ajax? Thank you.  You will need to use Ajax.Net to return the data.Don't forget to click "Mark as Answer" on the post that helped you....

Web resources about - How can I reset the style of GridView from client-side....???? -

Client-side scripting - Wikipedia, the free encyclopedia
... different and changing content depending on user input, environmental conditions (such as the time of day), or other variables. Client-side ...

Senior Search Manager - Client Side!!
... strategy insight for senior IT management - resources to understand and leverage information technology. Senior Search Manager - Client Side ...

Account Manager - Client Side - Previous Agency Experience Welcome!!
Computerworld Australia is the leading source of technology news, analysis and tools for IT decision makers, managers and professionals.

Media Sales Executive - Client Side!!
Technology news and reviews for business and home.

PPC Paid Search Manager - CLIENT SIDE
Defining Technology for Australia's IT Leaders. PPC Paid Search Manager - SEM - **CLIENT SIDE** Sydney CBD Location Client side!! SEM/PPC/Paid ...

How Basecamp Next got to be so damn fast without using much client-side UI
When we started working on Basecamp Next last year, we had much internal debate about whether we should evolve the existing code base or rewrite ...

Seven Tips for Pitching From the Client's Side of the Table
I had a chance to sit on the other side of the pitch table. Here is what I learned.

Client-side coding: How to prevent malicious use?
Applications that run on a user-controlled device cannot be perfectly protected.

The client side
... regarding the professionals you seek to assist. Even better if you possess that understanding yourself, having worked on the client side. I'm ...

Ecommerce traffic being hijacked by client side malware
According to new research 15 to 30 percent of eCommerce site visitors are infected with Client Side Injected Malware (CSIM) that causes them ...

Resources last updated: 11/23/2015 7:53:13 PM