Newbie Question!

Discussion in 'ASP .Net' started by Israel Richner, Oct 24, 2006.

  1. 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
     
    Israel Richner, Oct 24, 2006
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    >
     
    Jesse Liberty, Oct 24, 2006
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > > 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
    > >
     
    Israel Richner, Oct 24, 2006
    #3
  4. Israel Richner

    sloan Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > > news:...
    > > > 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
    > > >

    >
     
    sloan, Oct 24, 2006
    #4
  5. 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" <> wrote in message
    news:...
    >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" <> wrote in message
    >> news:...
    >> > 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
    >> >

    >
     
    John Timney \(MVP\), Oct 24, 2006
    #5
  6. 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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > > > news:...
    > > > > 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
    > > > >

    > >
     
    Israel Richner, Oct 25, 2006
    #6
  7. 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" <> wrote in message
    > > news:...
    > > > 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" <> wrote in message
    > > > > news:...
    > > > > > 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
    > > > > >
    > > >
     
    Flinky Wisty Pomm, Oct 25, 2006
    #7
  8. 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" <> wrote in message
    > > > news:...
    > > > > 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" <> wrote in message
    > > > > > news:...
    > > > > > > 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
    > > > > > >
    > > > >
     
    Israel Richner, Oct 25, 2006
    #8
  9. Israel Richner

    Mark Rae Guest

    "Israel Richner" <> wrote in message
    news:...

    > 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.
     
    Mark Rae, Oct 25, 2006
    #9
  10. Israel Richner

    BillE Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    >> > > news:...
    >> > > > 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" <> wrote in message
    >> > > > > news:...
    >> > > > > > 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
    >> > > > > >
    >> > > >

    >
     
    BillE, Oct 25, 2006
    #10
  11. Ok, you've all be very helpful.

    Thanks,
    Izzy

    BillE wrote:
    > 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" <> wrote in message
    > news:...
    > > 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" <> wrote in message
    > >> > > news:...
    > >> > > > 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" <> wrote in message
    > >> > > > > news:...
    > >> > > > > > 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
    > >> > > > > >
    > >> > > >

    > >
     
    Israel Richner, Oct 25, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry C.
    Replies:
    8
    Views:
    256
    Uri Guttman
    Nov 23, 2003
  2. Kruno Saho
    Replies:
    0
    Views:
    149
    Kruno Saho
    Apr 7, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    130
    Dave Angel
    Apr 7, 2013
  4. rusi
    Replies:
    0
    Views:
    117
  5. Miki Tebeka
    Replies:
    0
    Views:
    88
    Miki Tebeka
    Apr 7, 2013
Loading...

Share This Page