how to create a dynamic table in a .net environnement
i use sql server for my databases
thanks
dynamic tablecreate a dynamic table
Page 1 of 1
5 Replies - 1855 Views - Last Post: 10 August 2010 - 09:55 AM
Replies To: dynamic table
#2
Re: dynamic table
Posted 09 August 2010 - 12:21 PM
You should really try before posting on a forum. The rules do ask for a best effort.
http://lmgtfy.com/?q...et+datagridview
http://lmgtfy.com/?q...et+datagridview
#3
Re: dynamic table
Posted 09 August 2010 - 01:56 PM
@danny_kay1710 do you realize that DIC is likely to pop up in a google search? So, not only is lmgtfy a slap in the face but there is a possibility for a continuous loop leading right back here. You should really refrain from using it. Don't be so mean to newbies!
Anyways, @thevest12000 this is a pretty novice question to ask.
It would be easier to help you if you showed us what you have tried so far to create your table because there are several ways to create it....
Whenever I have a question regarding something .NET related I first refer to the MSDN Library. This library contains documentation about all .NET controls, concepts, patterns/practices and more. It's a great place to start when you don't know about something. There you will find documentation about the SqlConnection class which lets you connect to a database, and the DataAdapter class which uses a SqlConnection to "Fill" a DataSet with populated DataTables!
There's a lot of information there. After you've gone through the links I've posted ...could you please post back with details on what exactly are you having difficulties with?
-Frinny
Anyways, @thevest12000 this is a pretty novice question to ask.
It would be easier to help you if you showed us what you have tried so far to create your table because there are several ways to create it....
Whenever I have a question regarding something .NET related I first refer to the MSDN Library. This library contains documentation about all .NET controls, concepts, patterns/practices and more. It's a great place to start when you don't know about something. There you will find documentation about the SqlConnection class which lets you connect to a database, and the DataAdapter class which uses a SqlConnection to "Fill" a DataSet with populated DataTables!
There's a lot of information there. After you've gone through the links I've posted ...could you please post back with details on what exactly are you having difficulties with?
-Frinny
This post has been edited by Frinavale: 10 August 2010 - 05:55 AM
#4
Re: dynamic table
Posted 10 August 2010 - 02:52 AM
Here is an example how to create dynamic table
I hope it help you mark it if yes
you can create table like
Table table1 = new Table();
if you want but i say use table control to place where you want it is good for alignment.
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string d1 = RadComboBox1.SelectedValue.ToString();
string s = RadComboBox2.SelectedValue.ToString();
if (d1 != "Select" || s != "Select")
{
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\afset.mdf;Integrated Security=True;User Instance=True");
SqlCommand c = new SqlCommand("select book,summary,date_added,bookname from profile WHERE Dept=@d1 AND sem=@s", con);
con.Open();
SqlDataReader dr = c.ExecuteReader();
if (dr.Read())
{
int er = 1;
for (int i = 0; i < er; i++)
{
TableRow tr = new TableRow();
{
TableCell tc = new TableCell();
{
Label l = new Label();
l.Text = dr["bookname"].ToString();
l.Font.Bold = true;
tc.Controls.Add(l);
tc.Width = 360;
}
tc.BackColor = ColorTranslator.FromHtml("#0099FF");
tr.Cells.Add(tc);
TableCell t2 = new TableCell();
{
Label lb = new Label();
lb.Text = dr["date_added"].ToString() + " " + "\n";
t2.Controls.Add(lb);
}
t2.BackColor = ColorTranslator.FromHtml("#0099FF");
t2.Width = 60;
tr.Cells.Add(t2);
}
TableRow tr2 = new TableRow();
{
TableCell t3 = new TableCell();
{
Label lb1 = new Label();
lb1.Text = dr["summary"].ToString();
t3.Controls.Add(lb1);
LinkButton l = new LinkButton();
l.PostBackUrl = dr["Book"].ToString();
l.Text = "Download";
t3.Controls.Add(l);
}
t3.BackColor = Color.Wheat;
t3.ColumnSpan=2;
tr.Cells.Add(t3);
}
TableRow tr3 = new TableRow();
{
TableCell tc = new TableCell();
{}
tc.ColumnSpan = 2;
tc.Height=10;
}
Table1.Rows.Add(tr);
Table1.Rows.Add(tr2);
}
}
con.Close();
}
}
catch (Exception ex)
{
HttpCookie m = new HttpCookie("exe");
m.Values["e"] = ex.StackTrace.ToString();
Response.Cookies.Add(m);
Response.Redirect("~\\Error.aspx");
}
}
I hope it help you mark it if yes
you can create table like
Table table1 = new Table();
if you want but i say use table control to place where you want it is good for alignment.
#5
Re: dynamic table
Posted 10 August 2010 - 08:38 AM
Also, you may wish to look into Repeaters, they are godly!
#6
Re: dynamic table
Posted 10 August 2010 - 09:55 AM
@Imdsm: you can use a Repeater to specify how DataTable's data is displayed to the end-user so that the user can interact with the data. They can be bound to a DataTable or any other collection of data. Repeaters don't really have anything to do with dynamically creating a DataTable...
-Frinny
-Frinny
This post has been edited by Frinavale: 10 August 2010 - 09:55 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|