engr
08-02-2007, 09:28 AM
can neone give me an idea on how to generate an html form from sql Server database.all the elements should be picked up from the database.
|
Click to See Complete Forum and Search --> : Generate form from SQL Server database engr 08-02-2007, 09:28 AM can neone give me an idea on how to generate an html form from sql Server database.all the elements should be picked up from the database. engr 08-02-2007, 09:30 AM everything...even the table containing the form is generated from the database. oomagnumoo 08-02-2007, 06:09 PM This is how I did it. I created a Table object on my .aspx page called ID=TableTerms. <asp:table id="TableTerms" runat="server" GridLines="Both" CellPadding="1" BorderStyle="None" Height="10px" CellSpacing="1" Width="550px" __designer:wfdid="w52"></asp:table> In my .cs file, I used. Note, QueryBuilder is a class I wrote myself. protected void PopulateTerms() { QueryBuilder termsQB = new QueryBuilder("AnalysisTerms"); DataSet termsDS = new DataSet(); db.SetAndExecuteSQLCommand(termsQB.GetQuery(), "Terms"); termsDS = db.GetDataSetResult(); TableRow locTr = new TableRow(); TableTerms.Rows.Add(locTr); TableCell locCell = new TableCell(); locCell.Text = ""; locTr.Cells.Add(locCell); foreach (DataRow dr in termsDS.Tables["Terms"].Rows) { RadioButton rb = new RadioButton(); rb.GroupName = "Group" + dr["ID"].ToString(); rb.Text = ""; rb.ID = "inc_" + dr["ID"].ToString(); rb.Visible = true; rb.Checked = false; locCellAnd.Controls.Add(rb); } The dynamically generated controls are simply a two step process. Creating the new control such as CheckBox nCkBox = new CheckBox(); then adding newly created variable nCkBox to the control of a parent item, (in the case above i"m adding it to a table cell. You can attach it to any item really such as Page.Controls.Add(). Hope this helps. engr 08-03-2007, 11:35 AM thanks!can u giv me an idea of it using classic asp becoz i'm coding through asp... lmf232s 08-03-2007, 05:51 PM engr, You can also just store all the html in a single column. Then on your page, get your data from the database and just display the data on the screen. Select PageContent From Page Where ContentId = 32 If Not oRS.EOF then Response.write oRS("PageContent") Else Response.write "Unable to load page" End If Where the column PageContent might look like this: <h1>This is the page title</h1><ul><li>List Item1</li><li>List Item2</li></ul> <table><tr><td>Header1</td><td>Header2</td></tr><tr><td>Value1</td><td>Value2</td></tr><tr><td><input type="button" name="cmdTest" value="Click Me"/> webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |