I am creating a runtime table which is taking values from the database, but the problem is that the all the rows of database table is showing in one column when running on browser, how to divide the data in two columns .
the code is shown below which is presenting the data in one column....

protected void Page_Load(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection("Data Source=SWATI;Initial    Catalog=jwellerydesign;Integrated Security=True");
    con.Open();
    SqlCommand com = new SqlCommand("select * from category", con);
    SqlDataReader dr = com.ExecuteReader();
    Table tb = new Table();
    while (dr.Read())
    {

        string a = dr.GetInt32(0).ToString();
        TableRow tr = new TableRow();
        ImageButton img = new ImageButton();

        TableCell td = new TableCell();

        img.ToolTip = dr.GetString(1);
        img.CommandArgument = a;
        img.Command += new CommandEventHandler(click);
        string filename = dr.GetString(2);

        img.ImageUrl = filename;
        img.ImageAlign = 0;

        td.Controls.Add(img);

        td.Height = Unit.Pixel(150);
        td.Width = Unit.Pixel(150);

        tr.Controls.Add(td);

        tb.Controls.Add(tr);
    }
    Panel1.Controls.Add(tb);
}

how to show same table data in two columns ???

Hi maybe you like to add more columns to your output of tables. td.Controls.Add(img);

td.Height = Unit.Pixel(150);
td.Width = Unit.Pixel(150);

tr.Controls.Add(td);

tb.Controls.Add(tr);
}
Panel1.Controls.Add(tb);

I only see you're adding only one column ([img] column). You must specify how many columns you want it to display. If you created a database in sql with three columns then:
SqlCommand com = new SqlCommand("select * from category", con);
will select all the columns in the database.

Thanks for reply , I want to show only image from the database table but all the entries of table are showing in one column , how is it possible to show these values in two columns, if I add two columns in this code then what code I'll have to write for it and how data from table will be add half in one column and half in another column .
If you didn't understand the query please tell me how can I add the .aspx page to this thread to show you??

printscreen the page and attach it here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.