Tracing data controls within data controls

I have a problem with tracing data controls within data controls. Below are the codes and the trace statements. Can anyone help me? Your help is very much appreciated.

private void InitializeComponent()
this.DataGrid1.ItemDataBound+=new DataGridItemEventHandler(DataGrid1_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load);
private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
DropDownList Dropdownlist1 = (DropDownList)e.Item.Controls[2].FindControl("Dropdownlist1");
Dropdownlist1.SelectedIndexChanged+=new EventHandler(Dropdownlist1_SelectedIndexChanged);
private void Dropdownlist1_SelectedIndexChanged(object sender, EventArgs e)
Error Message:-
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
ViewBill: DataGrid1 System.Web.UI.WebControls.DataGrid
ViewBill:DataGrid1:_ctl0 System.Web.UI.WebControls.DataGridTable
ViewBill: DataGrid1:_ctl1 System.Web.UI.WebControls.DataGridItem
ViewBill: DataGrid1:_ctl1:_ctl0 System.Web.UI.WebControls.TableCell
ViewBill: DataGrid1:_ctl1:_ctl1 System.Web.UI.WebControls.TableCell
ViewBill: DataGrid1:_ctl1:_ctl2 System.Web.UI.WebControls.TableCell
ViewBill: DataGrid1:_ctl2 System.Web.UI.WebControls.DataGridItem
ViewBill: DataGrid1:_ctl2:_ctl0 System.Web.UI.WebControls.TableCell
ViewBill: DataGrid1:_ctl2:_ctl1 System.Web.UI.DataBoundLiteralControl
ViewBill: DataGrid1:_ctl2:_ctl2 System.Web.UI.WebControls.TableCell
ViewBill: DataGrid1:_ctl2:_ctl3 System.Web.UI.LiteralControl
ViewBill: DataGrid1:_ctl2: Dropdownlist1 System.Web.UI.WebControls.DropDownList
ViewBill: DataGrid1:_ctl2:_ctl4 System.Web.UI.LiteralControl
ViewBill: DataGrid1:_ctl2:_ctl5 System.Web.UI.WebControls.TableCell
ViewBill: DataGrid1:_ctl2:_ctl6 System.Web.UI.LiteralControl
ViewBill: DataGrid1:_ctl2:Button1 System.Web.UI.WebControls.Button
ViewBill: DataGrid1:_ctl2:_ctl7 System.Web.UI.LiteralControl
DropDownList Dropdownlist1 = (DropDownList)e.Item.Controls[ 2 ].FindControl("Dropdownlist1");
i'm tracing the control using this statement, but still same error.. any idea??

2/6/2004 8:02:25 AM 93655 articles. 6 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 39


Similar Artilces:

UpdatePanel within a web user control resets data of controls outside the user control
Hello, I have a usercontrol on my page which displays a running marquee text. It makes use of an UpdatePanel (within the user control) to refresh the marquee text (within the updatepanel) at periodic intervals. For this I added a timer control and its tick event as an async postback trigger for the UpdatePanel. I have a lot of textboxes and dropdown list boxes (all with runat=server) on the page outside the above user control. These are also contained in different UpdatePanels. Problem is, when the user control does a postback to refresh the marquee text, it causes some of...

How to Bind Data to Whole Web Form not in Data Control
How to Bind Data to Whole Web Form not in Data Control. To Get Data Like <%= %> One way to do it would be to create properties in your page class and then set them at Page_Load retrieving your data from whatever source. Can I ask why you would not want to use .Nets data controls? They make life so much easier.~mike~ agree with mike.  just drop in a literal and set literal's text property. Another advantage to that is if your "form" is editable, upon post back, values are retained automatically without the need to bind from datasource again...most of the time anyway. Then agai...

Using Data Control in another data control
Hey, How to use a SqlDataSource control in a GridView and so on...I mean i wanna show data which comes from UserTables in a gridview whoses data comes from ContentTable so they are two separated tables. Thanks and Regards...I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)] I mean how to use nested gridview controls. Please aren't there any poeple who can help me ?I am not a perfect programmer, but i have perfect programmers' habits [ i think so :)] Try the links below, they might be of some help to you.http://msdn2.microso...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

Bind Data to an Image Control not in a Data Presentation Control
I've been searching for two days but I don't really know what to search for.I'm making a site for a photographer.  The Default.aspx page displays Albums by showing a title, image and description from the database table Albums. Click an album to view the contents and it passes the QueryString which is AlbumName.  The ViewAlbum.aspx page uses the QueryString to display an UpdatePanel holding a Large Image and a Repeater full of dynamically filled ImageButtons for thumbs.  Both are from the database table Photos and are retrieved using an ObjectDataSource. Click the ...

Pass data from Web User Control to Web Form
I have a Web Form that contains a Web User Control. The WUC displays dynamic content. I want to change the TITLE property of the Web Form, based on the contents of the WUC. For example, if the WUC displays information about Horses, I want to change the page title to "HORSES" by passing the string to the parent Web Form. I have tried playing with parameters and such, but I can't remember how I did this in the past. PLEASE HELP!~o0 Spin-Monkey Oo~ The best way to do this is by creating a public property on your web user control and accessing that from your web form. Check ...

Persisting data in a web user control, which contains a list of other web user controls.
 Hi All, I have a control I've created, which can have a number of child controls - also user controls - stored as an ArrayList, which can be added wither a design time or programmatically.My problem is when I add to the list programmatically, it doesn't persist them. So if I add 3 child controls in step 1 of a wizard, with the aim that those three will be visible inside the parent in step 3, what happens is that the parent has no child controls and the item count is 0.Can anyone help? Thanks in advance.Code:Parent Control Markup: <%@ Control Language="C#" Auto...

user control data entry form, use same codebehind as web form?
Hi All, I have a quesiton about the approach I'm taking. I have a series of report forms which I have been in the process of consolidating to a single, generic page and subs/functions in a single code-behind. All the reports can use the same set of data entry elements (a dropdown, a radio list, and a textbox). I'm trying to convert these elements to a user control. However, this user control seems to need to inherit differently than the rest of the code-behind. I've been using a single class in the code behind. Is it feasible to separate out the data entry? the code behind im...

Visibility control of Panel control and its affect on data controls
Thought I would toss this out here this morning and perhaps someone else had run across the same issue and had found a good way to accomplish what I want. First let me state what I'm attempting to do and the problem that I've run into.  GridView1 has a collection of rows in a SQL table that I want to present to the user. I've provided them the options of sorting and selecting only from the GridView control.  Orgionally, I had created a detail view that was being presented in Edit mode and then customized the layout of the edit item template to suit my needs.&nbs...

how to htmlencode data when using data controls to display data
Hi Lets say you are displaying a colllection of records in a gridview and you want to make sure all of the rows and columns are html encoded before you display them, how can can you get the gridview to do this automatically? I don't want to have to create a template for each bound column. Thanks very much andrea Hi Andrea, I believe there is a "HtmlEncode" property on each column that you can set.  By default I believe it is set to true.  You can pull up the column editor by selecting the "edit columns" task, and then select the columns in the botton left of the dialog to see...

how to clear the data in all controls in a web form??
hi, can any one helpme to clear the contents of all controls in a web form. in vb i used like this dim ctl as control for each ctl in me.controls if type of ctl is textbox then ctl.text="" end if nextJayakumar Hi, Take a look @ Clear Form Fields HTH K B ShajudeenAreYaar.comDubai, United Arab Emirates. hi, i go through the code but it did not work for is not giving any is not clear the data.Jayakumar...

Controlling web control instances on Web Form
I have created a composite control, extending functionality of the Hidden Control. However, I would like to prevent the user from adding this control to the page multiple times. I only want one instance of the control on the Web Form. What setting in my project to I adjust to enable this functionality? I can not find it in any of the books that I have referenced. Is this a setting or is this code that has to be added to the inheriting class. Looks like there is no standard apporach. But I'd consider using static field to count number of created objects and throw exception if second object ...

In repeater, share web user control data between control instances
I have a user control which is repeated for each item in the repeater. The control uses some table data in order to populate a dropdownlist and an image. Because the control is repeated, I only want to fetch the data once and then reuse it. Ideally, I'd like the control to handle this data sharing rather than making the page responsible. Please note that this is in ASP.NET 1.1. Is it possible to save the data to the page's viewstate from the user control? From the user control, doesn't seem to expose a ViewState property. I appreciate any suggestions. Thanks in advance....

Web resources about - Tracing data controls within data controls -

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

The US needs gun control to protect children like my grandson, killed at Sandy Hook
Motives do not matter to the dead. They don't matter much to survivors, either.

Control traffic as a cat sheriff in Street Fever: City Adventure
... as you play Marty the cat sheriff in this new part arcade, part puzzle game from Meow Studio. In Street Fever: City Adventure you will control ...

The little box that controls half your home’s energy use
(credit: Nest Labs) A thermostat can be such a simple device—so dumb a device if we’re feeling 21 st Century snobby—that a strip of metal coiled ...

How to perform Jedi mind control tricks using neuroscience
... looking for..." With those words, Obi Wan Kenobi inspired a generation of nerdy young men to try their hands at performing Jedi mind control ...

Sandy Hook parents assess victories, defeats in gun control mission
CBS News Sandy Hook parents assess victories, defeats in gun control mission CBS News NEWTOWN, Conn. Three years ago on Monday, a gunman opened ...

How to use iOS or Apple Watch as remote controls with Apple TV
... new feature for Apple TV owners using Apple Watch, iPad or iPhones last week – the capacity to use your iOS device as a remote control for your ...

Hilarious: ‘Burglars For Gun Control’ Sums Up The Left’s Entire Argument
'As long as law abiding citizens have guns, it's that much harder for burglars like me to do my job.'

Bart & Fleming: Don’t Come To Year-End Movies To Get Laid; Time For Movies About Gun Control Debate?
Peter Bart and Mike Fleming Jr. worked together for two decades at Daily Variety . In this weekly Sunday column, two old friends get together ...

Halo 5 is getting advanced control options
... is a good day. There's more to next week's update for Halo 5: Guardians than Forge mode, maps, and REQs. The game is also expanding its control ...

Resources last updated: 12/15/2015 8:45:38 PM