I'm not too clear about what you're asking. Say you have a table with the ID myTable, a row with the ID myTableRow, and a cell myTableCell, and on some event you want to create a textbox with a value and an id, here's how you would do it:
private void Page_Load(object sender, System.EventArgs e)
{
//I assume you're getting your values correctly from SQL
// also assuming that you've passed your values into variables
// which i'll name myTextBoxID and myTextBoxValue
//Create a textbox control
TextBox _tb = new TextBox();
//Set the id of the textbox
_tb.ID = myTextBoxID;
//Set the value of the textbox
_tb.Text = myTextBoxValue;
//Add the control to your table cell
myTableCellID.Controls.Add(_tb);
}
Now I put the code to build the textbox in the page_load event handler, but you would probably make it a separate function call. Also, remember that dynamic content must be built every time you post the page; for some reason it disappears on postback if you don't call it again.
Also, it is very easy to create Tables, rows, and cells dynamically, and if you need the code to do this as well, please send me an email. I hope this helps.
|