CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

MS SQL 2008 on ASP.NET Hosting



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 3/4/2004 8:30:29 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 44 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
bgibilaro
Asp.Net User
Customer DataGrid User Control3/4/2004 8:30:29 PM

0/0

Hey,

Here is my problem. I wanted to create a very simply user control with a pre-formatted datagrid control.

Here is my .aspx code:


<%@ Control Language="vb" AutoEventWireup="false" Codebehind="importC.ascx.vb" Inherits="vaco2003_dev.importC" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<asp:datagrid id="dgrdReport" BorderWidth="1px" BorderStyle="Solid" BorderColor="#CCCCCC" Width="100%"
AutoGenerateColumns="False" GridLines="Horizontal" PageSize="50" runat="server">
<AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Top"></AlternatingItemStyle>
<ItemStyle Font-Size="11px" Font-Names="Arial,Helvetica,sans-serif" HorizontalAlign="Left"
ForeColor="Black" VerticalAlign="Top" BackColor="White"></ItemStyle>
<HeaderStyle Font-Size="11px" Font-Names="Arial,Helvetica,sans-serif" Font-Bold="True" HorizontalAlign="Left"
ForeColor="Black" VerticalAlign="Top" BackColor="#DFDFDF"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="cust_ref" HeaderText="Cust Ref #s">
<ItemStyle BackColor="#ECF0F4"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="hotListLink" CommandName="Edit" Runat="Server">
<%# Container.DataItem("hotListLink") %>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Select" DataTextField="file_no" HeaderText="File #"></asp:ButtonColumn>
<asp:BoundColumn DataField="ship_vessel" HeaderText="Shipper&lt;br&gt;Vessel">
<ItemStyle BackColor="#ECF0F4"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="container_no" HeaderText="Container #s"></asp:BoundColumn>
<asp:BoundColumn DataField="master_house" HeaderText="Master B/L&lt;br&gt;House B/L">
<ItemStyle BackColor="#ECF0F4"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="d2" HeaderText="Doc Recv.">
<HeaderStyle HorizontalAlign="Right" VerticalAlign="Top"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="d10" HeaderText="Dsp POI">
<HeaderStyle HorizontalAlign="Right" VerticalAlign="Top"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" VerticalAlign="Top" BackColor="#ECF0F4"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="d11_d215" HeaderText="ETAPOE&lt;br&gt;ATAPOE">
<HeaderStyle HorizontalAlign="Right" VerticalAlign="Top"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="d16_d212" HeaderText="EnSub Date&lt;br&gt;Rls Date">
<HeaderStyle HorizontalAlign="Right" VerticalAlign="Top"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" VerticalAlign="Top" BackColor="#ECF0F4"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="d24_d227" HeaderText="TrkNo&lt;br&gt;TrkPu">
<HeaderStyle HorizontalAlign="Right" VerticalAlign="Top"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" VerticalAlign="Top"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="d108_d20" HeaderText="FDAt&lt;br&gt;FDAc">
<HeaderStyle HorizontalAlign="Right" VerticalAlign="Top"></HeaderStyle>
<ItemStyle HorizontalAlign="Right" VerticalAlign="Top" BackColor="#ECF0F4"></ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:datagrid>



On the code behind, I have this:


Imports System
Imports System.Web
Imports System.Data
Imports System.Data.SqlClient

Public Class importC
Inherits System.Web.UI.UserControl

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected WithEvents dgrdReport As System.Web.UI.WebControls.DataGrid

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Public Property datasource()
Get
Return dgrdReport.DataSource
End Get
Set(ByVal Value)
dgrdReport.DataSource = Value
End Set
End Property
End Class


However, when I call the control from another page like so:

Dim myDgrd As New importC
myDgrd.DataSource = source
myDgrd.DataBind()

I get the following error:

Object reference not set to an instance of an object

And it refers to the line in my control code behind where I set the value


Set(ByVal Value)
dgrdReport.DataSource = Value
End Set


What am I doing wrong?

Thanks for the help!

Bob Gibilaro
master4eva
Asp.Net User
Re: Customer DataGrid User Control3/7/2004 8:43:45 AM

0/0

Load the user control like this:

importC c = (importC)LoadControl("importC.ascx");
c.datasource = source;
c.DataBind();
Controls.Add(c);

-- Justin Lovell
bgibilaro
Asp.Net User
Re: Customer DataGrid User Control3/8/2004 6:03:47 PM

0/0

You are a God!!!

That one stupid thing was holding up a major project.

Thanks so much. I appreciate it.

Bob Gibilaro
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
ASP.NET: Tips, Tutorials, and Code Authors: Scott Mitchell, Pages: 878, Published: 2002
Real World Asp.Net Best Practices: Best Practices and Fatal Traps Authors: Farhan Muhammad, Matt Milner, Pages: 224, Published: 2003
Professional C# Authors: Simon Robinson, Christian Nagel, Karli Watson, Jay Glynn, Morgan Skinner, Bill Evjen, Pages: 1224, Published: 2004
Introduction to Programming with Visual Basic .NET Authors: Gary J. Bronson, David A. Rosenthal, Pages: 756, Published: 2004
Distributed Data Applications with ASP.NET Authors: Alex Homer, Dave Sussman, Pages: 786, Published: 2003
VB.NET Developer's Guide: Developer's Guide Authors: Cameron Wakefield, Henk-Evert Sonder, Wei Meng Lee, Pages: 784, Published: 2001
ASP.Net Web Developer's Guide: Web Developer's Guide Authors: Robert Patton, Mesabāha Āhamada, Mesbah Ahmed, Jonothon Ortiz, Pages: 736, Published: 2002
MCAD/MCSD Training Guide (70-315): Developing and Implementing Web Applications with Visual C# and Visual Studio. NET Authors: Amit Kalani, Pages: 1200, Published: 2002
Developing Rich Clients with Macromedia Flex: FLEX Authors: Steven Webster, Alistair McLeod, Pages: 720, Published: 2004
Professional C# 2005 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Allen Jones, Pages: 1540, Published: 2006

Web:
DataGrid Class (System.Windows.Controls) Columns> ... GetSampleCustomerList() End Sub End Class Public Class Customer Dim m_FirstName ...
CodeProject: An ASP.NET DataGrid Custom Control to Freeze Header ... An ASP.net DataGrid Custom Control which allows freezing of header, columns, ... UseAccessibleHeader = true; //If user hasnt set height property set a ...
A Cup of Silverlight, RIA & Interoperability : eclipse4SL ... . Notice that as you have dropped a DataGrid on to the XAML code, .... The following code defines a Customer class composed of a Name, ...
Asp.Net DataGrid from SQL UserControl Stock Photo, Video SoftwareAsp.Net Image Upload ComponentAsp.Net Upload ComponentAsp.Net Custom DataGrid WebControlAsp.Net DataGrid from SQL UserControl ASP. ...
CodeGuru: Creating a Custom DataGrid Paging Control Feb 6, 2007 ... Create your own custom DataGrid paging control over which you, ... In Visual Studio, add a new web user control to your project and name it ...
CodeProject: Datagrid custom control to change the row color on ... Datagrid control with mouse over event to change the row color as Code Project; ... NET custom control. SqlWhereBuilder ASP.NET Server Control. A user ...
How do we build a custom control using datagrid from scratch ... User Control Panel, Private Messages, Subscriptions, Who's Online, Search Forums , Forums Home ... custom datagrid control for reuse, Sulafa Malik, ASP. ...
Editing a record from a datagrid. customer record in the datagrid that when clicked takes the user to an ... and for including dropdownlists, checkboxes, user controls and ...
Set DataGrid ItemSource is very slow : The Official Microsoft ... Columns> ...
CodeGuru Forums - Create custom datagrid from scratch As of today,I have actually gone ahead and created a user control that emulates the datagrid. I have used panels and labels for this. ...




Search This Site:










cookies not working

built-in function to reverse y to n and vice versa

virtualpathprovider without an .aspx file

if then, else question

system.io.file

moving to next record in an access database

creating own extension in .net

edit sitemap node

using registerstartup script in module.vb

extracting values from an arraylist

db driven video embedding

audio music live streaming

re: server.mappath question

using data in eventarg - best practice.

can't load the page in a browser

microsoft certification

3-tier architecture design - a few questions

page opens in vs.net- (odd error opening excel)

how to log out programatically using form-based authentication in asp.net 2.0

integrating with asp.net 2.0 membership, roles and forms authentication

how to create the sessions in asp.net

run process

vb.net code works but not c# code - please help

why some some server text boxes have yellow background color but some white background color?

when i used a stored procedure i get an error: failed to convert string to type guid

how to: read and write binary images

retrieving values

how to extract object attribute value which in arraylist?

(win2000 sp4 iis5 .net1.1) aspnet account

sql server 2005 ctp & visual web developer express

  Privacy | Contact Us
All Times Are GMT