You must Sign In to post a response.
  • Category: ASP.NET

    Create Div Dynamically using Database

    i want to create dynamically div using database

    In database record as follows
    In LatestNewsMaster table record as follows

    ID Subject Description Link
    1 Accounts Accounts fee page Accountsfees.aspx
    2 Defects Defects mail report Defects.aspx

    my code as follows

    string constr = ConfigurationManager.ConnectionStrings["Reception2_DB"].ConnectionString;
    using (SqlConnection con = new SqlConnection(constr))
    {
    sing (SqlCommand cmd = new SqlCommand("select Subject,Description,Link from LatestNewsMaster where active <> 'd'"))
    {
    cmd.Connection = con;
    using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
    {
    DataTable dt = new DataTable();
    sda.Fill(dt);
    for (int i = 0; i<dt.rows.count;> {
    lblSub.Text += dt.Rows[i][0].ToString().Trim() + "
    ";
    lbldesc.Text += dt.rows[i][1].ToString().Trim() +"
    ";
    llbLink.Text += dt.rows[i][2].ToString().Trim() + "
    ";
    }
    }
    }


    When i run the above code output as follows

    Accounts (Subject Displayed from the database)
    Defects (Subject Displayed from the database)
    Accounts fee page (Description Displayed from the database)
    Defects mail report (Description Displayed from the database)
    Accountsfees.aspx (Link Displayed from the database)
    Defects.aspx (Link Displayed from the database)

    But i want the above ouptut to be displayed as follows

    Subject Description Link
    Accounts Accounts fee page Accountsfees.aspx
    Defects Defects mail report Defects.aspx
  • #763785
    Hai Rao,
    If you want to display the records i n tabular format, then you can create the table dynamically.
    First create a table:

    Table table= new Table();

    Now add a row to the table:

    TableRow tr = new TableRow();

    Now add this row to the table:

    table.Rows.Add(tr);

    To create the cell, you can use :

    TableCell tc1 = new TableCell();
    tr.Cells.Add(tc1);

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #763815
    1. Place the three labels in different columns
    <table>
    <tr>
    <td>
    First Label
    </td>
    <td>
    Second Label
    </td>
    <td>
    Third Label
    </td>
    <tr>
    </table>

    2. You can go for repeater or data list and assign the data source so that u can handle this in the aspx page

    By Nathan
    Direction is important than speed


Sign In to post your comments