473,396 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to insert value in dropdownlist in the footer row of gridview?

I have Gridview with Template Field.And I Put Dropdownlist at footer row of gridview. but when i insert the value from a database table in dropdownlist , than it generate error.
for filling value ,

i declare variable like in databound event of gridview.
for example:

dim varclass as new dropdownlist
varclass=Gridview1.footerRow.findcontrol("ddlClass ")

it generate error that: Object reference not set to an instance of an object.
So any one have Answer??
Jan 12 '10 #1
1 4180
Frinavale
9,735 Expert Mod 8TB
You should be checking to make sure that the row being bound is the Footer and not a Header or Data row. If you try to access a variable in the footer row when it isn't the footer row that is being bound then you'll have a problem.

For example:
Expand|Select|Wrap|Line Numbers
  1. Private Sub myGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles myGridView.RowDataBound
  2.  
  3.   Select Case e.Row.RowType
  4.     Case DataControlRowType.Header
  5.       'In this case the header row is being bound 
  6.       'All controls in the header row are accessible
  7.     Case DataControlRowType.DataRow
  8.       'In this case a Data Row is being bound
  9.       'All controls in the data row are accessible
  10.     Case DataControlRowType.Footer
  11.       'In this case the footer row is being bound
  12.       'All controls in the footer row are now accessible
  13.     Case DataControlRowType.Pager
  14.       'In this case the pager row is being bound
  15.       'All controls in the pager row are accessible
  16. '....
  17.   End Select
  18.  
  19. End Sub
The controls available to you all depends on which row is currently being bound. If the row being bound is a data row, then obviously you wont find controls that are in the footer row.

When you use the findControl method you should always make sure that the control was found before you try to use it (check to make sure that the control IsNot Nothing before you try to use it)

-Frinny
Jan 13 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Hennie | last post by:
I have a textbox in the Footer of a Gridview. When I run an insert command I get the following error: " Object reference not set to an instance of an object. Description: An unhandled exception...
1
by: Hennie | last post by:
Hi Is it possible to insert records using the Footer row in a Gridview? I can do it with a datagrid in VS2003, but the same code in VS2005 give me an error: The code is: Dim strOperatorID As...
6
by: AG | last post by:
ASP.NET 2.0 aspx page with a FormView bound to an ObjectDataSource to view, add and edit records. Can anyone point me to a sample of how to retain the user entered control values when an insert...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
1
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList is...
0
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList...
2
by: shapper | last post by:
Hello, I am working with a ListView but I suppose that with a GridView might be the same. Instead of having an Insert Button on each GridView row I would like to have only one Insert button,...
0
by: troydixon | last post by:
Hello, I am new at this, and have been trying to insert data into a table by using the footer of a gridview (which I dont like) or by using a detials view on the same page that is doing the...
0
by: dcollier9 | last post by:
Hi ! I need to embed a text box in a footer of a GridView's boundfield column to get data prior to a row insert. The textbox is usable and showing up in the web page source using View
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.