---
title: "Double Click Row of GridView"  
description: "Double Click Row of GridView"  
author: "Anonymous User"  
published: 2013-12-17  
updated: 2013-12-17  
canonical: https://www.mindstick.com/forum/1787/double-click-row-of-gridview  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 2 minutes  

---

# Double Click Row of GridView

I want to [double click](https://www.mindstick.com/forum/155692/what-is-dfp-double-click-for-publisher) the row of a [GridView](https://www.mindstick.com/articles/873/update-delete-edit-gridview-in-asp-dot-net) and be redirected to a page that [shows](https://yourviews.mindstick.com/view/81380/new-york-violent-shooting-shows-people-are-not-safe-in-night-life) the details of the row that was clicked.

I have code that I'm working with and it seems like it should work, but I'm getting the [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) "Object [reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php) not set to an [instance of an object](https://www.mindstick.com/forum/376/system-nullreferenceexception-object-reference-not-set-to-an-instance-of-an-object)".

For some reason the row [comes up](https://answers.mindstick.com/qa/45369/if-you-search-worst-bollywood-actor-on-google-guess-whose-name-comes-up) null and I'm not sure why.

My code is below, can someone see what I'm [doing wrong](https://answers.mindstick.com/qa/36736/what-are-indians-doing-wrong-on-whatsapp)?

```
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" EnableViewState="true" OnDataBound="GridView1_DataBound" OnRowDataBound="GridView1_RowDataBound"    AllowSorting="True" AutoGenerateColumns="False" BorderStyle="Solid" GridLines="Both" HeaderStyle-BackColor="#990033" Width="1000px"    DataSourceID="EntityDataSource1">     <HeaderStyle ForeColor="White"></HeaderStyle>    <Columns>                   <asp:TemplateField>            <ItemTemplate>                <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Bind("intBatchID") %>' NavigateUrl="TestPage1.aspx?intBatchID={0}" Target="_blank"></asp:HyperLink>            </ItemTemplate>        </asp:TemplateField>        <asp:BoundField DataField="vcharName" HeaderText="Name" ReadOnly="True"            SortExpression="vcharName" />        <asp:BoundField DataField="dtmScheduled" HeaderText="Date Scheduled"            ReadOnly="True" SortExpression="dtmScheduled" />        <asp:BoundField DataField="intBatchPriorityLevel"            HeaderText="Priority Level" ReadOnly="True"            SortExpression="intBatchPriorityLevel" />    </Columns>    <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" PageButtonCount="4" PreviousPageText="Previous" NextPageText="Next" FirstPageText="First" LastPageText="Last" />    <PagerStyle HorizontalAlign="Center" />       </asp:GridView>  You are viewing page <%=GridView1.PageIndex + 1%> of <%=GridView1.PageCount%><asp:EntityDataSource ID="EntityDataSource1" runat="server" OnSelected="EntityDataSource1_Selected"     ConnectionString="name=TestEntities" DefaultContainerName="TestEntities"    EnableFlattening="False" EntitySetName="tbl_Batch"    Select="it.[intBatchID], it.[vcharName], it.[dtmScheduled], it.[intBatchPriorityLevel]" OrderBy="it.[intBatchID]"></asp:EntityDataSource>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)    {        if (e.Row.RowType == DataControlRowType.DataRow)        {            System.Data.DataRowView drv = e.Row.DataItem as System.Data.DataRowView;            e.Row.Attributes.Add("ondblclick", String.Format("window.location='TestPage1.aspx?intBatchID={0}'", drv["intBatchID"]));        }        if (e.Row.RowType == DataControlRowType.DataRow)        {            e.Row.Attributes.Add("onMouseOver", "Highlight(this)");            e.Row.Attributes.Add("onMouseOut", "UnHighlight(this)");        }    }
```

## Replies

### Reply by Pravesh Singh

Hi Tanuj,\

Try this :

```
protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e){    if (e.Row.RowType== DataControlRowType.DataRow)    {       
System.Data.DataRowView drv = e.Row.DataItem as System.Data.DataRowView;        if (drv !=null && Convert.IsDBNull(drv["intBatchID"]))           
e.Row.Attributes.Add("ondblclick",String.Format("window.location='TestPage1.aspx?intBatchID={0}'",
drv["intBatchID"]));       
e.Row.Attributes.Add("onMouseOver","Highlight(this)");       
e.Row.Attributes.Add("onMouseOut","UnHighlight(this)");    }}
```


---

Original Source: https://www.mindstick.com/forum/1787/double-click-row-of-gridview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
