table to label - basics(asp&c#)
-
1.I have a table(with 1 row) and i whant do create as many labels as columns. Each label has to have the text equal to a column name and the position: x:24 for everyone and label1 y = 60 label2 y = 120 label3 y= 180 and so on. All this has to be made throw c# code. 2. How do i put the text from a textbox in a table? PLZ HELP
-
1.I have a table(with 1 row) and i whant do create as many labels as columns. Each label has to have the text equal to a column name and the position: x:24 for everyone and label1 y = 60 label2 y = 120 label3 y= 180 and so on. All this has to be made throw c# code. 2. How do i put the text from a textbox in a table? PLZ HELP
what do you mean with table a dataTable object or a database table? If it is a database witch kind of database and how do you connect with it? anyway. you can get the label property text and with it do and update if it is database table: "alter table 'tablename' add column (label.text.toUpper() datatipe(length))" if you are talking about a datatable is even easier datatablename.columns.add("label.text"); hopefully it will help you NOthing by now;)
-
what do you mean with table a dataTable object or a database table? If it is a database witch kind of database and how do you connect with it? anyway. you can get the label property text and with it do and update if it is database table: "alter table 'tablename' add column (label.text.toUpper() datatipe(length))" if you are talking about a datatable is even easier datatablename.columns.add("label.text"); hopefully it will help you NOthing by now;)
-
10x table object. but how do i create as many labels as column whit the propety label1.text equal to evry column name. ex: label1.text = the name of the first column from the table. can anyone write the code for this.
//i have not tryed the code so it might have some errors but i think you can get the idea //SQL_COMMANDS (this commands will work only if you have a SQL Database) //this command will return all the non system tables SELECT Table_Name AS NOMBRE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE ' //this will return all the column names from a given database and table SELECT COLUMN_NAME as column FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME string Query = "SELECT COLUMN_NAME as column FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME LIKE 'the_name_of_your_table' //first you have to get all the column names of your table Cache = new System.Data.DataSet(); using (SqlConnection Conn = new SqlConnection(this.Conexion)) { SqlDataAdapter SqlDs = new SqlDataAdapter(Query,Conn); Conn.Open(); SqlDs.Fill(Cache,NombreTabla); } //now you have all the column names and you have to iterate as many times as columns you have creating and adding to your form a lavel //note that in your case the location will have to be assign dinamicly foreah(DataRow row in Cache.DataTable["NombreTabla"].rows) { System.Windows.Forms.Label MyLabel = new System.Windows.Forms.Label(); MyLabel .Location = new System.Drawing.Point(64, 64); MyLabel .Name = row[0].tostring(); MyLabel .Size = new System.Drawing.Size(376, 64); MyLabel .TabIndex = 0; MyLabel .Text = row[0].tostring(); //here we add the new label to the form this.controls.add(MyLabel) } //i hope the code above can help you NOthing by now;)