Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using a grid view.. In it, i am using a javascript to redirect page.. if user clicks on a row of a gridview, the page is redirected to itself with certain buttons made visible on redirect.. so when a page is redirected, i want the background color of the row selected to be blue... i had tried the code below but it does not works.. can anyone help me???
C#
protected void GridViewJobList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {


C#
string primaryKey = DataBinder.Eval(e.Row.DataItem, "Entry_No") + "";

C#
if (e.Row.DataItem == primarykey)
           {
               e.Row.BackColor = System.Drawing.Color.Blue;
           }

       }



}
Posted

use ajax hovermenuextender refer document on following link
https://docs.google.com/file/d/0B6KVMR-4BUaFdXB0MnV2cFNNdlU/edit[^]
 
Share this answer
 
Comments
Codes DeCodes 11-Jan-14 3:02am    
man guess u did not got me... what i wanted is to select the row based on primary key.. i have used javascript to extract primary key from grid.. now as page refresh, the row that has that primary key must be selected as blue...
Hi Jack.

You can try like this.

1) After getting the primary key from gridview using javascript, you can pass the primarykey as query string in the url
example ( window.location = ' your url.aspx?Key='your key' )

2) And in the page load method you can check the query string for that particular key as below.

C#
string _primaryKey = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                _primaryKey = Request.QueryString["key"];
            }
        }

        protected void GridViewJobList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string primaryKey = DataBinder.Eval(e.Row.DataItem, "Entry_No") + "";
                if (primaryKey == _primaryKey)
                    e.Row.BackColor = System.Drawing.Color.Blue;
            }
        }
 
Share this answer
 
Comments
Codes DeCodes 11-Jan-14 23:47pm    
thanks man,,
Karthik_Mahalingam 12-Jan-14 0:07am    
welcome jack :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900