This is a discussion on Object reference not set to an instance of an object within the .Net Development forums, part of the Programming & Scripting category; err msg: and yes i did read the sticky Code: Object reference not set to an instance of an object. ...
| |||||||
|
#1
| ||||
| ||||
| err msg: and yes i did read the sticky ![]() Code: 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. Source Error: Line 329: Line 330: Dim lbPageNumber As LinkButton Line 331: lbPageNumber.Text = x.ToString() Line 332: lbPageNumber.CommandName = "PageNumber" Line 333: lbPageNumber.CommandArgument = x Source File: C:\Inetpub\wwwroot\keithdesign\views\projects.aspx.vb Line: 331 Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] view_projects.DrawPaging(Int32 pageNumber, Int32 pageCount) in C:\Inetpub\wwwroot\keithdesign\views\projects.aspx.vb:331 view_projects.Populate_rpProjectList(Params myParams) in C:\Inetpub\wwwroot\keithdesign\views\projects.aspx.vb:83 view_projects.Page_Load() in C:\Inetpub\wwwroot\keithdesign\views\projects.aspx.vb:26 System.Web.Util.CalliHelper.ArglessFunctionCaller(IntPtr fp, Object o) +5 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +858603 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436 Code: Dim x, y, z, pageEnd, pageStart As Integer
For x = pageStart To pageEnd
If x = pageNumber Then
'sb.Append("<strong>[")
'sb.Append(x)
'sb.Append("]</strong> ")
Dim lbPageNumber As LinkButton
lbPageNumber.Text = x
lbPageNumber.CommandName = "PageNumber"
lbPageNumber.CommandArgument = x
lbPageNumber.Visible = True
lbPageNumber.Enabled = False
lbPageNumber.Font.Bold = True
AddHandler lbPageNumber.Command, AddressOf lblPageLinks_OnClick
pnlPagelinks.Controls.Add(lbPageNumber)
Else
'sb.Append("<a href=")
'sb.Append(DrawLink(x))
'sb.Append(">")
'sb.Append(x)
'sb.Append("</a> ")
Dim lbPageNumber As LinkButton
lbPageNumber.Text = x
lbPageNumber.CommandName = "PageNumber"
lbPageNumber.CommandArgument = x
lbPageNumber.Visible = True
AddHandler lbPageNumber.Command, AddressOf lblPageLinks_OnClick
pnlPagelinks.Controls.Add(lbPageNumber)
End If
Next
Shem |
|
#2
| ||||
| ||||
| I think it's because you don't set the instance of the LinkButton to an actual control on your page, so there's no instance of it. It would be:- Code: Dim lbPageNumber As New LinkButton Code: Dim lbPageNumber As LinkButton = your_linkbutton_id Code: Dim lbPageNumber As LinkButton = some_control.FindControl("your_linkbutton_id")
|
| The Following User Says Thank You to richyrich For This Useful Post: | ||
Shem (July 22nd, 2008) | ||
|
#3
| ||||
| ||||
| i'm trying to add LinkButton Controls to a panel control dynamically? |
|
#4
| ||||
| ||||
| Quote:
![]() Code: Dim lbPageNumber As New LinkButton |
|
#5
| ||||
| ||||
| W00T it works, and they are all added to my Panle Control too now just to make sure that the events fire off ![]() Shem |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VBScript Functions Reference | jmurrayhead | ASP Development | 25 | October 21st, 2008 08:31 AM |
| Dynamically Reference Worksheet Cell/Range | BLaaaaaaaaaarche | Microsoft Office | 2 | June 18th, 2008 03:59 PM |
| Object reference not set to an instance of an object | jmurrayhead | .Net Development | 1 | May 29th, 2008 10:16 AM |
| [Error] Object Required?!?!? | jarvelous | ASP Development | 2 | March 20th, 2008 12:46 PM |