Click here to Skip to main content
14,668,823 members
Rate this:
Please Sign up or sign in to vote.
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???
protected void GridViewJobList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {


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

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

       }



}
Posted

Rate this:
Please Sign up or sign in to vote.

Solution 1

use ajax hovermenuextender refer document on following link
https://docs.google.com/file/d/0B6KVMR-4BUaFdXB0MnV2cFNNdlU/edit[^]
   
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...
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.

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;
            }
        }
   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100