Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > C# only DataGrid for WebForm? EASY QUES!!!

Reply
Thread Tools

C# only DataGrid for WebForm? EASY QUES!!!

 
 
R Reyes
Guest
Posts: n/a
 
      10-24-2005
Hi,

I am trying to create a C# only website and can't seem to figure out why my
datagrid isn't showing?

All that's in my aspx file is:
<%@ Page Language="C#" AutoEventWireup="false" CodeFile="myPage.aspx.cs"
Inherits="myPage" %>

And in the code-behind I have:
HtmlForm form = new HtmlForm();
form.Controls.Add(dg);
this.Controls.AddAt(0, new LiteralControl(@"<html><head><title>HELLO
WORLD</title></head><body>"));
this.Controls.Add(form);
this.Controls.Add(new LiteralControl(@"</body></html>"));

This should be pretty straight forward HELLO WORLD page. The data is bound
to my datagrid also. I've tried adding the form and datagrid to different
controls in the controls collection to no avail. I am guessing there are
some datagrid properties such as height, width, ID, yada yada I need defined
that are not. Unless, someone knows the cause of this is from something
else???

Well anyway, the datagrid properties are:
// Main properties
dgEmployeeDirectory.ID = "dgEmployeeDirectory";
dgEmployeeDirectory.Height = 500;
dgEmployeeDirectory.Width = 500;
dgEmployeeDirectory.CellPadding = 5;
dgEmployeeDirectory.CellSpacing = 0;
dgEmployeeDirectory.GridLines = GridLines.Both;
dgEmployeeDirectory.BorderColor = Color.Blue;
dgEmployeeDirectory.ShowHeader = true;
dgEmployeeDirectory.SelectedItemStyle.BackColor = Color.Yellow;

// Paging properties
dgEmployeeDirectory.AutoGenerateColumns = false;
dgEmployeeDirectory.AllowPaging = true;
dgEmployeeDirectory.AllowSorting = true;
dgEmployeeDirectory.PageSize = 20;
dgEmployeeDirectory.PagerStyle.HorizontalAlign = HorizontalAlign.Left;
dgEmployeeDirectory.PagerStyle.Mode = PagerMode.NumericPages;
dgEmployeeDirectory.DataKeyField = "EmployeeID";
dgEmployeeDirectory.Visible = true;
dgEmployeeDirectory.Width = Unit.Pixel(76;

I've defined as many as I can...Anyone know what I might be missing? I've
been stumped for a few hours now...

Thanks in advance!
 
Reply With Quote
 
 
 
 
R Reyes
Guest
Posts: n/a
 
      10-24-2005
Oops, didn't realize there was an asp.net form already in there...From my
understanding (probably wrong now that you replied) I thought I was
"creating" the html form using the literal controls (containing
html/head/body tags) and htmlform control (form tag), to which then I can add
the datagrid.

You replied to my last post about viewstate titled "Failed to load
viewstate" saying that I should try to add the controls programatically with
C# and not hardcoded in ASP.NET so, this is my sorry attempt at that solution
and probably misunderstood you...

In short...I really have no idea why I was trying to add an HTML form to an
ASP.NET form. I'm still on the wrong track...and thinking of the wrong
solutions. Sorry about that.

"Alvin Bruney - ASP.NET MVP" wrote:

> why are you adding an html form inside of the asp.net form?
>
> --
> Regards,
> Alvin Bruney [MVP ASP.NET]
>
> [Shameless Author plug]
> The Microsoft Office Web Components Black Book with .NET
> Now Available @ www.lulu.com/owc
> Forth-coming VSTO.NET - Wrox/Wiley 2006
> -------------------------------------------------------
>
>
>
> "R Reyes" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> >
> > I am trying to create a C# only website and can't seem to figure out why

> my
> > datagrid isn't showing?
> >
> > All that's in my aspx file is:
> > <%@ Page Language="C#" AutoEventWireup="false" CodeFile="myPage.aspx.cs"
> > Inherits="myPage" %>
> >
> > And in the code-behind I have:
> > HtmlForm form = new HtmlForm();
> > form.Controls.Add(dg);
> > this.Controls.AddAt(0, new LiteralControl(@"<html><head><title>HELLO
> > WORLD</title></head><body>"));
> > this.Controls.Add(form);
> > this.Controls.Add(new LiteralControl(@"</body></html>"));
> >
> > This should be pretty straight forward HELLO WORLD page. The data is

> bound
> > to my datagrid also. I've tried adding the form and datagrid to different
> > controls in the controls collection to no avail. I am guessing there are
> > some datagrid properties such as height, width, ID, yada yada I need

> defined
> > that are not. Unless, someone knows the cause of this is from something
> > else???
> >
> > Well anyway, the datagrid properties are:
> > // Main properties
> > dgEmployeeDirectory.ID = "dgEmployeeDirectory";
> > dgEmployeeDirectory.Height = 500;
> > dgEmployeeDirectory.Width = 500;
> > dgEmployeeDirectory.CellPadding = 5;
> > dgEmployeeDirectory.CellSpacing = 0;
> > dgEmployeeDirectory.GridLines = GridLines.Both;
> > dgEmployeeDirectory.BorderColor = Color.Blue;
> > dgEmployeeDirectory.ShowHeader = true;
> > dgEmployeeDirectory.SelectedItemStyle.BackColor = Color.Yellow;
> >
> > // Paging properties
> > dgEmployeeDirectory.AutoGenerateColumns = false;
> > dgEmployeeDirectory.AllowPaging = true;
> > dgEmployeeDirectory.AllowSorting = true;
> > dgEmployeeDirectory.PageSize = 20;
> > dgEmployeeDirectory.PagerStyle.HorizontalAlign =

> HorizontalAlign.Left;
> > dgEmployeeDirectory.PagerStyle.Mode = PagerMode.NumericPages;
> > dgEmployeeDirectory.DataKeyField = "EmployeeID";
> > dgEmployeeDirectory.Visible = true;
> > dgEmployeeDirectory.Width = Unit.Pixel(76;
> >
> > I've defined as many as I can...Anyone know what I might be missing? I've
> > been stumped for a few hours now...
> >
> > Thanks in advance!

>
>
>

 
Reply With Quote
 
 
 
 
R Reyes
Guest
Posts: n/a
 
      10-24-2005
Fixed this myself. Basically I just had to remove all the datagrid property
code that i was presetting. Once removed the datagrid showed.

Removed all that looks like this...
> > > dgEmployeeDirectory.ID = "dgEmployeeDirectory";
> > > dgEmployeeDirectory.Height = 500;
> > > dgEmployeeDirectory.Width = 500;
> > > dgEmployeeDirectory.CellPadding = 5;
> > > dgEmployeeDirectory.CellSpacing = 0;
> > > dgEmployeeDirectory.GridLines = GridLines.Both;
> > > dgEmployeeDirectory.BorderColor = Color.Blue;
> > > dgEmployeeDirectory.ShowHeader = true;
> > > dgEmployeeDirectory.SelectedItemStyle.BackColor = Color.Yellow;
> > >
> > > // Paging properties
> > > dgEmployeeDirectory.AutoGenerateColumns = false;
> > > dgEmployeeDirectory.AllowPaging = true;
> > > dgEmployeeDirectory.AllowSorting = true;
> > > dgEmployeeDirectory.PageSize = 20;
> > > dgEmployeeDirectory.PagerStyle.HorizontalAlign =

> > HorizontalAlign.Left;
> > > dgEmployeeDirectory.PagerStyle.Mode = PagerMode.NumericPages;
> > > dgEmployeeDirectory.DataKeyField = "EmployeeID";
> > > dgEmployeeDirectory.Visible = true;
> > > dgEmployeeDirectory.Width = Unit.Pixel(76;


"R Reyes" wrote:

> Oops, didn't realize there was an asp.net form already in there...From my
> understanding (probably wrong now that you replied) I thought I was
> "creating" the html form using the literal controls (containing
> html/head/body tags) and htmlform control (form tag), to which then I can add
> the datagrid.
>
> You replied to my last post about viewstate titled "Failed to load
> viewstate" saying that I should try to add the controls programatically with
> C# and not hardcoded in ASP.NET so, this is my sorry attempt at that solution
> and probably misunderstood you...
>
> In short...I really have no idea why I was trying to add an HTML form to an
> ASP.NET form. I'm still on the wrong track...and thinking of the wrong
> solutions. Sorry about that.
>
> "Alvin Bruney - ASP.NET MVP" wrote:
>
> > why are you adding an html form inside of the asp.net form?
> >
> > --
> > Regards,
> > Alvin Bruney [MVP ASP.NET]
> >
> > [Shameless Author plug]
> > The Microsoft Office Web Components Black Book with .NET
> > Now Available @ www.lulu.com/owc
> > Forth-coming VSTO.NET - Wrox/Wiley 2006
> > -------------------------------------------------------
> >
> >
> >
> > "R Reyes" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hi,
> > >
> > > I am trying to create a C# only website and can't seem to figure out why

> > my
> > > datagrid isn't showing?
> > >
> > > All that's in my aspx file is:
> > > <%@ Page Language="C#" AutoEventWireup="false" CodeFile="myPage.aspx.cs"
> > > Inherits="myPage" %>
> > >
> > > And in the code-behind I have:
> > > HtmlForm form = new HtmlForm();
> > > form.Controls.Add(dg);
> > > this.Controls.AddAt(0, new LiteralControl(@"<html><head><title>HELLO
> > > WORLD</title></head><body>"));
> > > this.Controls.Add(form);
> > > this.Controls.Add(new LiteralControl(@"</body></html>"));
> > >
> > > This should be pretty straight forward HELLO WORLD page. The data is

> > bound
> > > to my datagrid also. I've tried adding the form and datagrid to different
> > > controls in the controls collection to no avail. I am guessing there are
> > > some datagrid properties such as height, width, ID, yada yada I need

> > defined
> > > that are not. Unless, someone knows the cause of this is from something
> > > else???
> > >
> > > Well anyway, the datagrid properties are:
> > > // Main properties
> > > dgEmployeeDirectory.ID = "dgEmployeeDirectory";
> > > dgEmployeeDirectory.Height = 500;
> > > dgEmployeeDirectory.Width = 500;
> > > dgEmployeeDirectory.CellPadding = 5;
> > > dgEmployeeDirectory.CellSpacing = 0;
> > > dgEmployeeDirectory.GridLines = GridLines.Both;
> > > dgEmployeeDirectory.BorderColor = Color.Blue;
> > > dgEmployeeDirectory.ShowHeader = true;
> > > dgEmployeeDirectory.SelectedItemStyle.BackColor = Color.Yellow;
> > >
> > > // Paging properties
> > > dgEmployeeDirectory.AutoGenerateColumns = false;
> > > dgEmployeeDirectory.AllowPaging = true;
> > > dgEmployeeDirectory.AllowSorting = true;
> > > dgEmployeeDirectory.PageSize = 20;
> > > dgEmployeeDirectory.PagerStyle.HorizontalAlign =

> > HorizontalAlign.Left;
> > > dgEmployeeDirectory.PagerStyle.Mode = PagerMode.NumericPages;
> > > dgEmployeeDirectory.DataKeyField = "EmployeeID";
> > > dgEmployeeDirectory.Visible = true;
> > > dgEmployeeDirectory.Width = Unit.Pixel(76;
> > >
> > > I've defined as many as I can...Anyone know what I might be missing? I've
> > > been stumped for a few hours now...
> > >
> > > Thanks in advance!

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it reasonably easy easy to something like this with python? Bruno Desthuilliers Python 5 08-29-2007 07:40 AM
Stripping audio from qa DVD. Easy or not so easy? GJ Computer Support 1 05-23-2007 02:03 AM
easy to look at and easy to maintain web page menuing system. Hazzard ASP .Net 2 04-06-2004 03:51 AM
DataGrid easy Edit-Update using ADO.NET/DataGrid functionality C#? Kostia ASP .Net Datagrid Control 1 02-26-2004 05:03 PM



Advertisments