Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Newbie Question!

Reply
Thread Tools

Newbie Question!

 
 
Israel Richner
Guest
Posts: n/a
 
      10-24-2006
How do I write information to a specific location on a web page from
the code behind page?

For instance I have 2 controls on my web form, in the code behind page
I query a database and read the results with a data reader. While
reading the records I format it into an html string like
"<table><tr><td>[inserted reader data]</td></tr></table>"

I know I can use Response.Write(string) but how do I control where that
new table gets written too? I want it placed between the two controls
on the form.

What am I missing?

Izzy

 
Reply With Quote
 
 
 
 
Jesse Liberty
Guest
Posts: n/a
 
      10-24-2006
First, while you can do what you are suggesting, you typically would place
an asp control into the table cell, and then you would write your data to
the text field or to an another appropriate property of that control. For
example, you might write

> "<table><tr><td><asp:label id="mylabel" runat="server"></td></tr></table>"


then in your code you can write

mylabel.Text = myTable.Row[0]["NameColumn"];

but all of this is assuming quite a bit about asp.net controls and adolnet
controls and quite a bit more. I strongly recommend that you find a book
that takes you through asp.net in a bit more orderly fashion so that it
doesn't all seem like such a muddle.

There are quite a few out there (I happen to like the O'Reilly book
Programming ASP.NET 2nd Edition, but I know the author). Go to a good book
store and read through a couple; it will be time and money well spent. Find
one that meets your style and needs and that tells the story step by step
but that focuses on the issues you care about.

Best of luck.

-j


--
Jesse Liberty
Microsoft MVP
Author/ Programmer
http://www.LibertyAssociates.com



"Israel Richner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> How do I write information to a specific location on a web page from
> the code behind page?
>
> For instance I have 2 controls on my web form, in the code behind page
> I query a database and read the results with a data reader. While
> reading the records I format it into an html string like
> "<table><tr><td>[inserted reader data]</td></tr></table>"
>
> I know I can use Response.Write(string) but how do I control where that
> new table gets written too? I want it placed between the two controls
> on the form.
>
> What am I missing?
>
> Izzy
>



 
Reply With Quote
 
 
 
 
Israel Richner
Guest
Posts: n/a
 
      10-24-2006
I have to build the table dynamically because the number of records are
unknown. So I won't know how many controls I need until the reader is
finished.

How would I accomplish this?

Thanks for the reply!

Izzy


Jesse Liberty wrote:
> First, while you can do what you are suggesting, you typically would place
> an asp control into the table cell, and then you would write your data to
> the text field or to an another appropriate property of that control. For
> example, you might write
>
> > "<table><tr><td><asp:label id="mylabel" runat="server"></td></tr></table>"

>
> then in your code you can write
>
> mylabel.Text = myTable.Row[0]["NameColumn"];
>
> but all of this is assuming quite a bit about asp.net controls and adolnet
> controls and quite a bit more. I strongly recommend that you find a book
> that takes you through asp.net in a bit more orderly fashion so that it
> doesn't all seem like such a muddle.
>
> There are quite a few out there (I happen to like the O'Reilly book
> Programming ASP.NET 2nd Edition, but I know the author). Go to a good book
> store and read through a couple; it will be time and money well spent. Find
> one that meets your style and needs and that tells the story step by step
> but that focuses on the issues you care about.
>
> Best of luck.
>
> -j
>
>
> --
> Jesse Liberty
> Microsoft MVP
> Author/ Programmer
> http://www.LibertyAssociates.com
>
>
>
> "Israel Richner" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > How do I write information to a specific location on a web page from
> > the code behind page?
> >
> > For instance I have 2 controls on my web form, in the code behind page
> > I query a database and read the results with a data reader. While
> > reading the records I format it into an html string like
> > "<table><tr><td>[inserted reader data]</td></tr></table>"
> >
> > I know I can use Response.Write(string) but how do I control where that
> > new table gets written too? I want it placed between the two controls
> > on the form.
> >
> > What am I missing?
> >
> > Izzy
> >


 
Reply With Quote
 
sloan
Guest
Posts: n/a
 
      10-24-2006
Izzy,

Its bad mojo to bring asp thinking to DotNet.
At least I think that is what you're doing. I'm not sure, but hopefully this
can help.


Here is some help:
If you want to use dynamic columns for your datasource, then you should
dynamically create your DataGrid.

Do a google search for

datagrid "new BoundColumn"



Here is some code I pulled from a hit (using that google search)

public void TestHyperLinkColumn()
{
// First add a simple bound column
BoundColumn nameColumn = new BoundColumn();
nameColumn.DataField = "ProductName";
nameColumn.DataFormatString = "{0}";
nameColumn.HeaderText = "Product";

// Now add the HyperLink column
HyperLinkColumn linkColumn = new HyperLinkColumn();
linkColumn.DataTextField = "ProductName";
linkColumn.DataTextFormatString = "{0} Details";
linkColumn.DataNavigateUrlField = "ProductID";
linkColumn.DataNavigateUrlFormatString =
"/MyApp/ProductDetails.aspx={0}";
linkColumn.HeaderText = "Details";

// Add the link in a BoundColumn
// where the text can be the same for all rows
BoundColumn blinkColumn = new BoundColumn();
blinkColumn.DataField = "ProductID";
blinkColumn.DataFormatString =
"<a href='/MyApp/ProductDetails.aspx={0}'>Details</a>";
blinkColumn.HeaderText = "Details";

DataGrid1.Columns.Add(nameColumn);
DataGrid1.Columns.Add(linkColumn);
DataGrid1.Columns.Add(blinkColumn);
DataGrid1.AutoGenerateColumns = false;

DataTable dt = GetNorthwindProductTable();
DataGrid1.DataSource = dt;
DataGrid1.DataBind();

}



NOW.. if you want the datagrid to show up at a specific place, then just
DRAG one onto the aspx page.
Assume (from above) that DataGrid1 has already been dragged onto your form.




"Israel Richner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> I have to build the table dynamically because the number of records are
> unknown. So I won't know how many controls I need until the reader is
> finished.
>
> How would I accomplish this?
>
> Thanks for the reply!
>
> Izzy
>
>
> Jesse Liberty wrote:
> > First, while you can do what you are suggesting, you typically would

place
> > an asp control into the table cell, and then you would write your data

to
> > the text field or to an another appropriate property of that control.

For
> > example, you might write
> >
> > > "<table><tr><td><asp:label id="mylabel"

runat="server"></td></tr></table>"
> >
> > then in your code you can write
> >
> > mylabel.Text = myTable.Row[0]["NameColumn"];
> >
> > but all of this is assuming quite a bit about asp.net controls and

adolnet
> > controls and quite a bit more. I strongly recommend that you find a book
> > that takes you through asp.net in a bit more orderly fashion so that it
> > doesn't all seem like such a muddle.
> >
> > There are quite a few out there (I happen to like the O'Reilly book
> > Programming ASP.NET 2nd Edition, but I know the author). Go to a good

book
> > store and read through a couple; it will be time and money well spent.

Find
> > one that meets your style and needs and that tells the story step by

step
> > but that focuses on the issues you care about.
> >
> > Best of luck.
> >
> > -j
> >
> >
> > --
> > Jesse Liberty
> > Microsoft MVP
> > Author/ Programmer
> > http://www.LibertyAssociates.com
> >
> >
> >
> > "Israel Richner" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) ups.com...
> > > How do I write information to a specific location on a web page from
> > > the code behind page?
> > >
> > > For instance I have 2 controls on my web form, in the code behind page
> > > I query a database and read the results with a data reader. While
> > > reading the records I format it into an html string like
> > > "<table><tr><td>[inserted reader data]</td></tr></table>"
> > >
> > > I know I can use Response.Write(string) but how do I control where

that
> > > new table gets written too? I want it placed between the two controls
> > > on the form.
> > >
> > > What am I missing?
> > >
> > > Izzy
> > >

>



 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      10-24-2006
Personally I hate tables, they are a pain to work with. I would bind the
data to a datagrid, stick it in a DIV and position the DIV. As long as your
layout is controlled by CSS you should be able to place things where you
like.

Follow Jessies suggestion - buy a book (actually buy Jessies book!)

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog


"Israel Richner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>I have to build the table dynamically because the number of records are
> unknown. So I won't know how many controls I need until the reader is
> finished.
>
> How would I accomplish this?
>
> Thanks for the reply!
>
> Izzy
>
>
> Jesse Liberty wrote:
>> First, while you can do what you are suggesting, you typically would
>> place
>> an asp control into the table cell, and then you would write your data to
>> the text field or to an another appropriate property of that control.
>> For
>> example, you might write
>>
>> > "<table><tr><td><asp:label id="mylabel"
>> > runat="server"></td></tr></table>"

>>
>> then in your code you can write
>>
>> mylabel.Text = myTable.Row[0]["NameColumn"];
>>
>> but all of this is assuming quite a bit about asp.net controls and
>> adolnet
>> controls and quite a bit more. I strongly recommend that you find a book
>> that takes you through asp.net in a bit more orderly fashion so that it
>> doesn't all seem like such a muddle.
>>
>> There are quite a few out there (I happen to like the O'Reilly book
>> Programming ASP.NET 2nd Edition, but I know the author). Go to a good
>> book
>> store and read through a couple; it will be time and money well spent.
>> Find
>> one that meets your style and needs and that tells the story step by step
>> but that focuses on the issues you care about.
>>
>> Best of luck.
>>
>> -j
>>
>>
>> --
>> Jesse Liberty
>> Microsoft MVP
>> Author/ Programmer
>> http://www.LibertyAssociates.com
>>
>>
>>
>> "Israel Richner" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) ups.com...
>> > How do I write information to a specific location on a web page from
>> > the code behind page?
>> >
>> > For instance I have 2 controls on my web form, in the code behind page
>> > I query a database and read the results with a data reader. While
>> > reading the records I format it into an html string like
>> > "<table><tr><td>[inserted reader data]</td></tr></table>"
>> >
>> > I know I can use Response.Write(string) but how do I control where that
>> > new table gets written too? I want it placed between the two controls
>> > on the form.
>> >
>> > What am I missing?
>> >
>> > Izzy
>> >

>



 
Reply With Quote
 
Israel Richner
Guest
Posts: n/a
 
      10-25-2006
I think maybe I was too vague in my description. Here is what I'll be
doing, I wrote this site using ASP.NET 2.0 www.svtn.com. If you
navigate to the employment page you'll see an online application for
drivers to apply online.

It was secured using SSL but it's not now. Long story.

Anyway, currently when a driver fills out the application and fills in
all required fields the data is inserted into 2 tables.

tbl_Applications
tbl_EmploymentHistory

Once that happens the "Confirmation" page loads querying for the data
and creating a crystal report which looks like an employment
application. The crystal report is loaded into a crystal report viewer
on the page.

Once the driver reviews the information and clicks submit a second
time, a pdf file gets created and then attached to an email and sent to
HR

I no longer want the website creating the pdf files, for security and
maintenance reasons, I wrote a windows service which queries the table
looking for new applications. This windows service handles creating the
pdf and emails it to HR. I only want the website saving the data once
it's confirmed to be accurate.

So to replace the "Confirmation" page crystal report viewer, I need to
display the data so that it looks like an employment application.
I don't know how much employment history is filled out, could be 2 or 3
or 4.
I don't think a datagrid will work here because the date won't be
displayed horizontally, it will look more like this.

Comany Name: Start Date:
Address: End Date:
City: State: Zip:

This format will repeat over and over again for each prior employer.

I do have some books, I plan to get my MCSD eventually. Just need to
find time to read them.

How would you guys accomplish this task?


sloan wrote:
> Izzy,
>
> Its bad mojo to bring asp thinking to DotNet.
> At least I think that is what you're doing. I'm not sure, but hopefully this
> can help.
>
>
> Here is some help:
> If you want to use dynamic columns for your datasource, then you should
> dynamically create your DataGrid.
>
> Do a google search for
>
> datagrid "new BoundColumn"
>
>
>
> Here is some code I pulled from a hit (using that google search)
>
> public void TestHyperLinkColumn()
> {
> // First add a simple bound column
> BoundColumn nameColumn = new BoundColumn();
> nameColumn.DataField = "ProductName";
> nameColumn.DataFormatString = "{0}";
> nameColumn.HeaderText = "Product";
>
> // Now add the HyperLink column
> HyperLinkColumn linkColumn = new HyperLinkColumn();
> linkColumn.DataTextField = "ProductName";
> linkColumn.DataTextFormatString = "{0} Details";
> linkColumn.DataNavigateUrlField = "ProductID";
> linkColumn.DataNavigateUrlFormatString =
> "/MyApp/ProductDetails.aspx={0}";
> linkColumn.HeaderText = "Details";
>
> // Add the link in a BoundColumn
> // where the text can be the same for all rows
> BoundColumn blinkColumn = new BoundColumn();
> blinkColumn.DataField = "ProductID";
> blinkColumn.DataFormatString =
> "<a href='/MyApp/ProductDetails.aspx={0}'>Details</a>";
> blinkColumn.HeaderText = "Details";
>
> DataGrid1.Columns.Add(nameColumn);
> DataGrid1.Columns.Add(linkColumn);
> DataGrid1.Columns.Add(blinkColumn);
> DataGrid1.AutoGenerateColumns = false;
>
> DataTable dt = GetNorthwindProductTable();
> DataGrid1.DataSource = dt;
> DataGrid1.DataBind();
>
> }
>
>
>
> NOW.. if you want the datagrid to show up at a specific place, then just
> DRAG one onto the aspx page.
> Assume (from above) that DataGrid1 has already been dragged onto your form.
>
>
>
>
> "Israel Richner" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > I have to build the table dynamically because the number of records are
> > unknown. So I won't know how many controls I need until the reader is
> > finished.
> >
> > How would I accomplish this?
> >
> > Thanks for the reply!
> >
> > Izzy
> >
> >
> > Jesse Liberty wrote:
> > > First, while you can do what you are suggesting, you typically would

> place
> > > an asp control into the table cell, and then you would write your data

> to
> > > the text field or to an another appropriate property of that control.

> For
> > > example, you might write
> > >
> > > > "<table><tr><td><asp:label id="mylabel"

> runat="server"></td></tr></table>"
> > >
> > > then in your code you can write
> > >
> > > mylabel.Text = myTable.Row[0]["NameColumn"];
> > >
> > > but all of this is assuming quite a bit about asp.net controls and

> adolnet
> > > controls and quite a bit more. I strongly recommend that you find a book
> > > that takes you through asp.net in a bit more orderly fashion so that it
> > > doesn't all seem like such a muddle.
> > >
> > > There are quite a few out there (I happen to like the O'Reilly book
> > > Programming ASP.NET 2nd Edition, but I know the author). Go to a good

> book
> > > store and read through a couple; it will be time and money well spent.

> Find
> > > one that meets your style and needs and that tells the story step by

> step
> > > but that focuses on the issues you care about.
> > >
> > > Best of luck.
> > >
> > > -j
> > >
> > >
> > > --
> > > Jesse Liberty
> > > Microsoft MVP
> > > Author/ Programmer
> > > http://www.LibertyAssociates.com
> > >
> > >
> > >
> > > "Israel Richner" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) ups.com...
> > > > How do I write information to a specific location on a web page from
> > > > the code behind page?
> > > >
> > > > For instance I have 2 controls on my web form, in the code behind page
> > > > I query a database and read the results with a data reader. While
> > > > reading the records I format it into an html string like
> > > > "<table><tr><td>[inserted reader data]</td></tr></table>"
> > > >
> > > > I know I can use Response.Write(string) but how do I control where

> that
> > > > new table gets written too? I want it placed between the two controls
> > > > on the form.
> > > >
> > > > What am I missing?
> > > >
> > > > Izzy
> > > >

> >


 
Reply With Quote
 
Flinky Wisty Pomm
Guest
Posts: n/a
 
      10-25-2006
ASP:Repeater - when all else fails. I use the repeater control more
than any other databound control because you get loads of scope for
mucking around with the format of your HTML.

<asp:repeater runat="server">
<HeaderTemplate>
<h2>Employment History</h2>
<div id="employmentHistory">
</HeaderTemplate>

<ItemTemplate>
<table>
...
</table>
</ItemTemplate>

<FooterTemplate>
</div>
</FooterTemplate>

</asp:Repeater>


Israel Richner wrote:

> I think maybe I was too vague in my description. Here is what I'll be
> doing, I wrote this site using ASP.NET 2.0 www.svtn.com. If you
> navigate to the employment page you'll see an online application for
> drivers to apply online.
>
> It was secured using SSL but it's not now. Long story.
>
> Anyway, currently when a driver fills out the application and fills in
> all required fields the data is inserted into 2 tables.
>
> tbl_Applications
> tbl_EmploymentHistory
>
> Once that happens the "Confirmation" page loads querying for the data
> and creating a crystal report which looks like an employment
> application. The crystal report is loaded into a crystal report viewer
> on the page.
>
> Once the driver reviews the information and clicks submit a second
> time, a pdf file gets created and then attached to an email and sent to
> HR
>
> I no longer want the website creating the pdf files, for security and
> maintenance reasons, I wrote a windows service which queries the table
> looking for new applications. This windows service handles creating the
> pdf and emails it to HR. I only want the website saving the data once
> it's confirmed to be accurate.
>
> So to replace the "Confirmation" page crystal report viewer, I need to
> display the data so that it looks like an employment application.
> I don't know how much employment history is filled out, could be 2 or 3
> or 4.
> I don't think a datagrid will work here because the date won't be
> displayed horizontally, it will look more like this.
>
> Comany Name: Start Date:
> Address: End Date:
> City: State: Zip:
>
> This format will repeat over and over again for each prior employer.
>
> I do have some books, I plan to get my MCSD eventually. Just need to
> find time to read them.
>
> How would you guys accomplish this task?
>
>
> sloan wrote:
> > Izzy,
> >
> > Its bad mojo to bring asp thinking to DotNet.
> > At least I think that is what you're doing. I'm not sure, but hopefully this
> > can help.
> >
> >
> > Here is some help:
> > If you want to use dynamic columns for your datasource, then you should
> > dynamically create your DataGrid.
> >
> > Do a google search for
> >
> > datagrid "new BoundColumn"
> >
> >
> >
> > Here is some code I pulled from a hit (using that google search)
> >
> > public void TestHyperLinkColumn()
> > {
> > // First add a simple bound column
> > BoundColumn nameColumn = new BoundColumn();
> > nameColumn.DataField = "ProductName";
> > nameColumn.DataFormatString = "{0}";
> > nameColumn.HeaderText = "Product";
> >
> > // Now add the HyperLink column
> > HyperLinkColumn linkColumn = new HyperLinkColumn();
> > linkColumn.DataTextField = "ProductName";
> > linkColumn.DataTextFormatString = "{0} Details";
> > linkColumn.DataNavigateUrlField = "ProductID";
> > linkColumn.DataNavigateUrlFormatString =
> > "/MyApp/ProductDetails.aspx={0}";
> > linkColumn.HeaderText = "Details";
> >
> > // Add the link in a BoundColumn
> > // where the text can be the same for all rows
> > BoundColumn blinkColumn = new BoundColumn();
> > blinkColumn.DataField = "ProductID";
> > blinkColumn.DataFormatString =
> > "<a href='/MyApp/ProductDetails.aspx={0}'>Details</a>";
> > blinkColumn.HeaderText = "Details";
> >
> > DataGrid1.Columns.Add(nameColumn);
> > DataGrid1.Columns.Add(linkColumn);
> > DataGrid1.Columns.Add(blinkColumn);
> > DataGrid1.AutoGenerateColumns = false;
> >
> > DataTable dt = GetNorthwindProductTable();
> > DataGrid1.DataSource = dt;
> > DataGrid1.DataBind();
> >
> > }
> >
> >
> >
> > NOW.. if you want the datagrid to show up at a specific place, then just
> > DRAG one onto the aspx page.
> > Assume (from above) that DataGrid1 has already been dragged onto your form.
> >
> >
> >
> >
> > "Israel Richner" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) ups.com...
> > > I have to build the table dynamically because the number of records are
> > > unknown. So I won't know how many controls I need until the reader is
> > > finished.
> > >
> > > How would I accomplish this?
> > >
> > > Thanks for the reply!
> > >
> > > Izzy
> > >
> > >
> > > Jesse Liberty wrote:
> > > > First, while you can do what you are suggesting, you typically would

> > place
> > > > an asp control into the table cell, and then you would write your data

> > to
> > > > the text field or to an another appropriate property of that control.

> > For
> > > > example, you might write
> > > >
> > > > > "<table><tr><td><asp:label id="mylabel"

> > runat="server"></td></tr></table>"
> > > >
> > > > then in your code you can write
> > > >
> > > > mylabel.Text = myTable.Row[0]["NameColumn"];
> > > >
> > > > but all of this is assuming quite a bit about asp.net controls and

> > adolnet
> > > > controls and quite a bit more. I strongly recommend that you find a book
> > > > that takes you through asp.net in a bit more orderly fashion so that it
> > > > doesn't all seem like such a muddle.
> > > >
> > > > There are quite a few out there (I happen to like the O'Reilly book
> > > > Programming ASP.NET 2nd Edition, but I know the author). Go to a good

> > book
> > > > store and read through a couple; it will be time and money well spent.

> > Find
> > > > one that meets your style and needs and that tells the story step by

> > step
> > > > but that focuses on the issues you care about.
> > > >
> > > > Best of luck.
> > > >
> > > > -j
> > > >
> > > >
> > > > --
> > > > Jesse Liberty
> > > > Microsoft MVP
> > > > Author/ Programmer
> > > > http://www.LibertyAssociates.com
> > > >
> > > >
> > > >
> > > > "Israel Richner" <(E-Mail Removed)> wrote in message
> > > > news:(E-Mail Removed) ups.com...
> > > > > How do I write information to a specific location on a web page from
> > > > > the code behind page?
> > > > >
> > > > > For instance I have 2 controls on my web form, in the code behind page
> > > > > I query a database and read the results with a data reader. While
> > > > > reading the records I format it into an html string like
> > > > > "<table><tr><td>[inserted reader data]</td></tr></table>"
> > > > >
> > > > > I know I can use Response.Write(string) but how do I control where

> > that
> > > > > new table gets written too? I want it placed between the two controls
> > > > > on the form.
> > > > >
> > > > > What am I missing?
> > > > >
> > > > > Izzy
> > > > >
> > >


 
Reply With Quote
 
Israel Richner
Guest
Posts: n/a
 
      10-25-2006
Does everyone agree the repeater control is the best solution?

My original plan was to build a html string in the code behind page
when the DataReader was reading the employment history. Then dump that
on the page, my only hurdle was figuring out how to tell the
Response.Write(strHTML) to place the data where I wanted it. The
formating would be handled in the .css file.

To be clear when the DataReader finished reading the records I would
have a string variable with the following value:

"<table><tr><dt>Employer Name: Some Company</td><td>Start Date: Some
date</td></tr></table>"

Obviously there is more data then that, but you get the idea.

I'm looking for the most efficient way of handling data.

So the question now is, is the repeater control the best method? Or is
Response.Write(strHTML) the best method?

Thanks everyone,
Izzy

Flinky Wisty Pomm wrote:
> ASP:Repeater - when all else fails. I use the repeater control more
> than any other databound control because you get loads of scope for
> mucking around with the format of your HTML.
>
> <asp:repeater runat="server">
> <HeaderTemplate>
> <h2>Employment History</h2>
> <div id="employmentHistory">
> </HeaderTemplate>
>
> <ItemTemplate>
> <table>
> ...
> </table>
> </ItemTemplate>
>
> <FooterTemplate>
> </div>
> </FooterTemplate>
>
> </asp:Repeater>
>
>
> Israel Richner wrote:
>
> > I think maybe I was too vague in my description. Here is what I'll be
> > doing, I wrote this site using ASP.NET 2.0 www.svtn.com. If you
> > navigate to the employment page you'll see an online application for
> > drivers to apply online.
> >
> > It was secured using SSL but it's not now. Long story.
> >
> > Anyway, currently when a driver fills out the application and fills in
> > all required fields the data is inserted into 2 tables.
> >
> > tbl_Applications
> > tbl_EmploymentHistory
> >
> > Once that happens the "Confirmation" page loads querying for the data
> > and creating a crystal report which looks like an employment
> > application. The crystal report is loaded into a crystal report viewer
> > on the page.
> >
> > Once the driver reviews the information and clicks submit a second
> > time, a pdf file gets created and then attached to an email and sent to
> > HR
> >
> > I no longer want the website creating the pdf files, for security and
> > maintenance reasons, I wrote a windows service which queries the table
> > looking for new applications. This windows service handles creating the
> > pdf and emails it to HR. I only want the website saving the data once
> > it's confirmed to be accurate.
> >
> > So to replace the "Confirmation" page crystal report viewer, I need to
> > display the data so that it looks like an employment application.
> > I don't know how much employment history is filled out, could be 2 or 3
> > or 4.
> > I don't think a datagrid will work here because the date won't be
> > displayed horizontally, it will look more like this.
> >
> > Comany Name: Start Date:
> > Address: End Date:
> > City: State: Zip:
> >
> > This format will repeat over and over again for each prior employer.
> >
> > I do have some books, I plan to get my MCSD eventually. Just need to
> > find time to read them.
> >
> > How would you guys accomplish this task?
> >
> >
> > sloan wrote:
> > > Izzy,
> > >
> > > Its bad mojo to bring asp thinking to DotNet.
> > > At least I think that is what you're doing. I'm not sure, but hopefully this
> > > can help.
> > >
> > >
> > > Here is some help:
> > > If you want to use dynamic columns for your datasource, then you should
> > > dynamically create your DataGrid.
> > >
> > > Do a google search for
> > >
> > > datagrid "new BoundColumn"
> > >
> > >
> > >
> > > Here is some code I pulled from a hit (using that google search)
> > >
> > > public void TestHyperLinkColumn()
> > > {
> > > // First add a simple bound column
> > > BoundColumn nameColumn = new BoundColumn();
> > > nameColumn.DataField = "ProductName";
> > > nameColumn.DataFormatString = "{0}";
> > > nameColumn.HeaderText = "Product";
> > >
> > > // Now add the HyperLink column
> > > HyperLinkColumn linkColumn = new HyperLinkColumn();
> > > linkColumn.DataTextField = "ProductName";
> > > linkColumn.DataTextFormatString = "{0} Details";
> > > linkColumn.DataNavigateUrlField = "ProductID";
> > > linkColumn.DataNavigateUrlFormatString =
> > > "/MyApp/ProductDetails.aspx={0}";
> > > linkColumn.HeaderText = "Details";
> > >
> > > // Add the link in a BoundColumn
> > > // where the text can be the same for all rows
> > > BoundColumn blinkColumn = new BoundColumn();
> > > blinkColumn.DataField = "ProductID";
> > > blinkColumn.DataFormatString =
> > > "<a href='/MyApp/ProductDetails.aspx={0}'>Details</a>";
> > > blinkColumn.HeaderText = "Details";
> > >
> > > DataGrid1.Columns.Add(nameColumn);
> > > DataGrid1.Columns.Add(linkColumn);
> > > DataGrid1.Columns.Add(blinkColumn);
> > > DataGrid1.AutoGenerateColumns = false;
> > >
> > > DataTable dt = GetNorthwindProductTable();
> > > DataGrid1.DataSource = dt;
> > > DataGrid1.DataBind();
> > >
> > > }
> > >
> > >
> > >
> > > NOW.. if you want the datagrid to show up at a specific place, then just
> > > DRAG one onto the aspx page.
> > > Assume (from above) that DataGrid1 has already been dragged onto your form.
> > >
> > >
> > >
> > >
> > > "Israel Richner" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) ups.com...
> > > > I have to build the table dynamically because the number of records are
> > > > unknown. So I won't know how many controls I need until the reader is
> > > > finished.
> > > >
> > > > How would I accomplish this?
> > > >
> > > > Thanks for the reply!
> > > >
> > > > Izzy
> > > >
> > > >
> > > > Jesse Liberty wrote:
> > > > > First, while you can do what you are suggesting, you typically would
> > > place
> > > > > an asp control into the table cell, and then you would write your data
> > > to
> > > > > the text field or to an another appropriate property of that control.
> > > For
> > > > > example, you might write
> > > > >
> > > > > > "<table><tr><td><asp:label id="mylabel"
> > > runat="server"></td></tr></table>"
> > > > >
> > > > > then in your code you can write
> > > > >
> > > > > mylabel.Text = myTable.Row[0]["NameColumn"];
> > > > >
> > > > > but all of this is assuming quite a bit about asp.net controls and
> > > adolnet
> > > > > controls and quite a bit more. I strongly recommend that you find a book
> > > > > that takes you through asp.net in a bit more orderly fashion so that it
> > > > > doesn't all seem like such a muddle.
> > > > >
> > > > > There are quite a few out there (I happen to like the O'Reilly book
> > > > > Programming ASP.NET 2nd Edition, but I know the author). Go to a good
> > > book
> > > > > store and read through a couple; it will be time and money well spent.
> > > Find
> > > > > one that meets your style and needs and that tells the story step by
> > > step
> > > > > but that focuses on the issues you care about.
> > > > >
> > > > > Best of luck.
> > > > >
> > > > > -j
> > > > >
> > > > >
> > > > > --
> > > > > Jesse Liberty
> > > > > Microsoft MVP
> > > > > Author/ Programmer
> > > > > http://www.LibertyAssociates.com
> > > > >
> > > > >
> > > > >
> > > > > "Israel Richner" <(E-Mail Removed)> wrote in message
> > > > > news:(E-Mail Removed) ups.com...
> > > > > > How do I write information to a specific location on a web page from
> > > > > > the code behind page?
> > > > > >
> > > > > > For instance I have 2 controls on my web form, in the code behind page
> > > > > > I query a database and read the results with a data reader. While
> > > > > > reading the records I format it into an html string like
> > > > > > "<table><tr><td>[inserted reader data]</td></tr></table>"
> > > > > >
> > > > > > I know I can use Response.Write(string) but how do I control where
> > > that
> > > > > > new table gets written too? I want it placed between the two controls
> > > > > > on the form.
> > > > > >
> > > > > > What am I missing?
> > > > > >
> > > > > > Izzy
> > > > > >
> > > >


 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      10-25-2006
"Israel Richner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...

> Does everyone agree the repeater control is the best solution?


Not for everything, but probably in this case...

> My original plan was to build a html string in the code behind page
> when the DataReader was reading the employment history. Then dump that
> on the page, my only hurdle was figuring out how to tell the
> Response.Write(strHTML) to place the data where I wanted it. The
> formating would be handled in the .css file.


That might be an acceptable solution if you were developing your site in ASP
Classic...

> I'm looking for the most efficient way of handling data.


Use one of the ASP.NET data webcontrols - that's what they're for...

> So the question now is, is the repeater control the best method?


Probably in this case.

> Or is Response.Write(strHTML) the best method?


Absolutely not.


 
Reply With Quote
 
BillE
Guest
Posts: n/a
 
      10-25-2006
I think the repeater is best, but you can build a table dynamically:
dim t as new Table
dim r as new TableRow
dim c as new TableCell
dim l as new Label
l.text = "label"
c.controls.add(l)
r.cells.add(c)
t.rows.ad(r)
Panel1.controls.add(t)


"Israel Richner" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Does everyone agree the repeater control is the best solution?
>
> My original plan was to build a html string in the code behind page
> when the DataReader was reading the employment history. Then dump that
> on the page, my only hurdle was figuring out how to tell the
> Response.Write(strHTML) to place the data where I wanted it. The
> formating would be handled in the .css file.
>
> To be clear when the DataReader finished reading the records I would
> have a string variable with the following value:
>
> "<table><tr><dt>Employer Name: Some Company</td><td>Start Date: Some
> date</td></tr></table>"
>
> Obviously there is more data then that, but you get the idea.
>
> I'm looking for the most efficient way of handling data.
>
> So the question now is, is the repeater control the best method? Or is
> Response.Write(strHTML) the best method?
>
> Thanks everyone,
> Izzy
>
> Flinky Wisty Pomm wrote:
>> ASP:Repeater - when all else fails. I use the repeater control more
>> than any other databound control because you get loads of scope for
>> mucking around with the format of your HTML.
>>
>> <asp:repeater runat="server">
>> <HeaderTemplate>
>> <h2>Employment History</h2>
>> <div id="employmentHistory">
>> </HeaderTemplate>
>>
>> <ItemTemplate>
>> <table>
>> ...
>> </table>
>> </ItemTemplate>
>>
>> <FooterTemplate>
>> </div>
>> </FooterTemplate>
>>
>> </asp:Repeater>
>>
>>
>> Israel Richner wrote:
>>
>> > I think maybe I was too vague in my description. Here is what I'll be
>> > doing, I wrote this site using ASP.NET 2.0 www.svtn.com. If you
>> > navigate to the employment page you'll see an online application for
>> > drivers to apply online.
>> >
>> > It was secured using SSL but it's not now. Long story.
>> >
>> > Anyway, currently when a driver fills out the application and fills in
>> > all required fields the data is inserted into 2 tables.
>> >
>> > tbl_Applications
>> > tbl_EmploymentHistory
>> >
>> > Once that happens the "Confirmation" page loads querying for the data
>> > and creating a crystal report which looks like an employment
>> > application. The crystal report is loaded into a crystal report viewer
>> > on the page.
>> >
>> > Once the driver reviews the information and clicks submit a second
>> > time, a pdf file gets created and then attached to an email and sent to
>> > HR
>> >
>> > I no longer want the website creating the pdf files, for security and
>> > maintenance reasons, I wrote a windows service which queries the table
>> > looking for new applications. This windows service handles creating the
>> > pdf and emails it to HR. I only want the website saving the data once
>> > it's confirmed to be accurate.
>> >
>> > So to replace the "Confirmation" page crystal report viewer, I need to
>> > display the data so that it looks like an employment application.
>> > I don't know how much employment history is filled out, could be 2 or 3
>> > or 4.
>> > I don't think a datagrid will work here because the date won't be
>> > displayed horizontally, it will look more like this.
>> >
>> > Comany Name: Start Date:
>> > Address: End Date:
>> > City: State: Zip:
>> >
>> > This format will repeat over and over again for each prior employer.
>> >
>> > I do have some books, I plan to get my MCSD eventually. Just need to
>> > find time to read them.
>> >
>> > How would you guys accomplish this task?
>> >
>> >
>> > sloan wrote:
>> > > Izzy,
>> > >
>> > > Its bad mojo to bring asp thinking to DotNet.
>> > > At least I think that is what you're doing. I'm not sure, but
>> > > hopefully this
>> > > can help.
>> > >
>> > >
>> > > Here is some help:
>> > > If you want to use dynamic columns for your datasource, then you
>> > > should
>> > > dynamically create your DataGrid.
>> > >
>> > > Do a google search for
>> > >
>> > > datagrid "new BoundColumn"
>> > >
>> > >
>> > >
>> > > Here is some code I pulled from a hit (using that google search)
>> > >
>> > > public void TestHyperLinkColumn()
>> > > {
>> > > // First add a simple bound column
>> > > BoundColumn nameColumn = new BoundColumn();
>> > > nameColumn.DataField = "ProductName";
>> > > nameColumn.DataFormatString = "{0}";
>> > > nameColumn.HeaderText = "Product";
>> > >
>> > > // Now add the HyperLink column
>> > > HyperLinkColumn linkColumn = new HyperLinkColumn();
>> > > linkColumn.DataTextField = "ProductName";
>> > > linkColumn.DataTextFormatString = "{0} Details";
>> > > linkColumn.DataNavigateUrlField = "ProductID";
>> > > linkColumn.DataNavigateUrlFormatString =
>> > > "/MyApp/ProductDetails.aspx={0}";
>> > > linkColumn.HeaderText = "Details";
>> > >
>> > > // Add the link in a BoundColumn
>> > > // where the text can be the same for all rows
>> > > BoundColumn blinkColumn = new BoundColumn();
>> > > blinkColumn.DataField = "ProductID";
>> > > blinkColumn.DataFormatString =
>> > > "<a href='/MyApp/ProductDetails.aspx={0}'>Details</a>";
>> > > blinkColumn.HeaderText = "Details";
>> > >
>> > > DataGrid1.Columns.Add(nameColumn);
>> > > DataGrid1.Columns.Add(linkColumn);
>> > > DataGrid1.Columns.Add(blinkColumn);
>> > > DataGrid1.AutoGenerateColumns = false;
>> > >
>> > > DataTable dt = GetNorthwindProductTable();
>> > > DataGrid1.DataSource = dt;
>> > > DataGrid1.DataBind();
>> > >
>> > > }
>> > >
>> > >
>> > >
>> > > NOW.. if you want the datagrid to show up at a specific place, then
>> > > just
>> > > DRAG one onto the aspx page.
>> > > Assume (from above) that DataGrid1 has already been dragged onto your
>> > > form.
>> > >
>> > >
>> > >
>> > >
>> > > "Israel Richner" <(E-Mail Removed)> wrote in message
>> > > news:(E-Mail Removed) ups.com...
>> > > > I have to build the table dynamically because the number of records
>> > > > are
>> > > > unknown. So I won't know how many controls I need until the reader
>> > > > is
>> > > > finished.
>> > > >
>> > > > How would I accomplish this?
>> > > >
>> > > > Thanks for the reply!
>> > > >
>> > > > Izzy
>> > > >
>> > > >
>> > > > Jesse Liberty wrote:
>> > > > > First, while you can do what you are suggesting, you typically
>> > > > > would
>> > > place
>> > > > > an asp control into the table cell, and then you would write your
>> > > > > data
>> > > to
>> > > > > the text field or to an another appropriate property of that
>> > > > > control.
>> > > For
>> > > > > example, you might write
>> > > > >
>> > > > > > "<table><tr><td><asp:label id="mylabel"
>> > > runat="server"></td></tr></table>"
>> > > > >
>> > > > > then in your code you can write
>> > > > >
>> > > > > mylabel.Text = myTable.Row[0]["NameColumn"];
>> > > > >
>> > > > > but all of this is assuming quite a bit about asp.net controls
>> > > > > and
>> > > adolnet
>> > > > > controls and quite a bit more. I strongly recommend that you find
>> > > > > a book
>> > > > > that takes you through asp.net in a bit more orderly fashion so
>> > > > > that it
>> > > > > doesn't all seem like such a muddle.
>> > > > >
>> > > > > There are quite a few out there (I happen to like the O'Reilly
>> > > > > book
>> > > > > Programming ASP.NET 2nd Edition, but I know the author). Go to a
>> > > > > good
>> > > book
>> > > > > store and read through a couple; it will be time and money well
>> > > > > spent.
>> > > Find
>> > > > > one that meets your style and needs and that tells the story step
>> > > > > by
>> > > step
>> > > > > but that focuses on the issues you care about.
>> > > > >
>> > > > > Best of luck.
>> > > > >
>> > > > > -j
>> > > > >
>> > > > >
>> > > > > --
>> > > > > Jesse Liberty
>> > > > > Microsoft MVP
>> > > > > Author/ Programmer
>> > > > > http://www.LibertyAssociates.com
>> > > > >
>> > > > >
>> > > > >
>> > > > > "Israel Richner" <(E-Mail Removed)> wrote in message
>> > > > > news:(E-Mail Removed) ups.com...
>> > > > > > How do I write information to a specific location on a web page
>> > > > > > from
>> > > > > > the code behind page?
>> > > > > >
>> > > > > > For instance I have 2 controls on my web form, in the code
>> > > > > > behind page
>> > > > > > I query a database and read the results with a data reader.
>> > > > > > While
>> > > > > > reading the records I format it into an html string like
>> > > > > > "<table><tr><td>[inserted reader data]</td></tr></table>"
>> > > > > >
>> > > > > > I know I can use Response.Write(string) but how do I control
>> > > > > > where
>> > > that
>> > > > > > new table gets written too? I want it placed between the two
>> > > > > > controls
>> > > > > > on the form.
>> > > > > >
>> > > > > > What am I missing?
>> > > > > >
>> > > > > > Izzy
>> > > > > >
>> > > >

>



 
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
newbie with newbie questions JohnE ASP .Net 3 08-17-2009 10:10 PM
VONAGE Newbie w/newbie question New_kid@nowhere.new VOIP 0 08-11-2007 01:40 PM
another newbie question from another newbie.... Lee UK VOIP 4 05-17-2005 04:10 PM
newbie: cisco vlan newbie question No Spam Cisco 3 06-07-2004 10:02 AM
Newbie! I'm a newbie! What's wrong with this program? Id0x Python 4 07-20-2003 11:40 PM



Advertisments