Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


resetting gridView SelectedRow.BackColor

Posted on 2009-04-16
Medium Priority
Last Modified: 2013-12-26
I currently have a gridView (gv_news) and a detailsView, the gridView shows a list of news items, with an alternatingRowStyle backColor of Grey and Transparent. The gridView also has a selectedRowStyle backColor of green:
<SelectedRowStyle BackColor="#CCFFCC" />
<AlternatingRowStyle BackColor="#EFEFEF" />

Now when I select an item in the grid view the item turns green, once I update the item or cancel the update in the detailsView I would like the selectedRowStyle in the gridView to be reset to the default alternatingRowStyle - as if nothing is selected any more.

I have created a function which I have bound the the detailsViews Update and Cancel buttons as show below. The error I receive, when one of these buttons is clicked is:
System.NullReferenceException: Object reference not set to an instance of an object.

I would appreciate some assistance in resolving this.

Many thanks,

Sub selectRemove()
    Dim gv_news As GridView = CType(Page.FindControl("gv_news"), GridView)
    gv_news.SelectedRow.BackColor = Drawing.Color.Transparent
End Sub

Open in new window

Question by:badstyle
1 Comment
LVL 14

Accepted Solution

GiftsonDJohn earned 500 total points
ID: 24161911

It is very simple. After updating the database, before rebinding to the dataset, do the following


It will reset the background color back to normal

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question