1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to add record inside the table

Discussion in 'C#' started by kharearch, May 12, 2008.

  1. #1
    I want to add a record inside the table for that I am using

    'method = "post" action = "list.aspx"'

    but it is not invoking list.aspx file.

    how can I invoke list.aspx file and receive variable on list.aspx file.
    Can you please send me a sample code. Simple code, may not be for inserting record inside the table but using 'method = "post" action = ""'.

    kharearch, May 12, 2008 IP
  2. nubsii

    nubsii Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    I'm not sure if this is what you want, but it uses the method/action described and writes something into a table from a variable in default.aspx.cs.

    ASPX code:
    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Some stuff in a table</title>
        <form id="form1" runat="server">
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    Code (markup):
    I believe the runat="" above is what will get written to html as method/action after the page is compiled+requested by a browser.

    Here's the codebehind for that page
    using System.Text;
    public partial class _Default : System.Web.UI.Page 
        protected void Page_Load(object sender, EventArgs e)
            string[] myHypotheticalData = 
                new string[3] { 
            StringBuilder sb = new StringBuilder();
            foreach (string record in myHypotheticalData)
                sb.Append("<tr>\n<td>" + record + "</td>\n</tr>\n");
            Label1.Text = sb.ToString();
    Code (markup):
    I created an array with 3 strings in it, I assembled them in a stringbuilder by appending the propper html markup per string, and then for simplicity I wrote the contents of my stringbuilder to a label. Realistically you would use something other than a label.
    nubsii, May 12, 2008 IP