1. Add the placeholder in the specified area on the page.
2. Add a control to placeholder.
Note:CodeIt must be placed in page_load and cannot be judged by ispostback. Otherwise, no control is found.
Sample Code:
String Ssql = "" ;
Ssql = @" Select sfcid, sfcdeptid, sfctablename, sfctabletitle
From hp_satisfactioncreate SSC " ;
Ssql = String . Format (ssql, resources. Resource. syssatisfactiondept );
Dataview dvdata = Tdaiclient. businessdb. getdataview (ssql );
If (Dvdata ! = Null )
{
// Add carriage return
// Literalcontrol lcval = new literalcontrol ("<br/> ");
// Add Space
// Literalcontrol lcspace = new literalcontrol (@ "& nbsp ;");
If (Dvdata. Count > 0 )
{
/*
* A two-column table is generated here.
*/
// Define table
Htmltable httab = New Htmltable ();
Httab. style. Add (htmltextwriterstyle. Width, " 100% " );
// Define rows in a table
Htmltablerow htrtr = New Htmltablerow ();
For ( Int Irow = 0 ; Irow < Dvdata. Count; irow ++ )
{
// Define an example in a row
Htmltablecell htctd = New Htmltablecell ();
Htctd. style. Add (htmltextwriterstyle. textalign, " Center " );
Htctd. style. Add (htmltextwriterstyle. color, " Blue " );
// Define the linkbutton Control
Linkbutton LBN = New Linkbutton ();
LBN. Text = Dvdata [irow] [ " Sfctabletitle " ]. Tostring ();
LBN. tooltip = Dvdata [irow] [ " Sfcid " ]. Tostring ();
String Surl = " Syssatisfactiondept. aspx? Strid = {0} " ;
Surl = String . Format (Surl, dvdata [irow] [ " Sfcid " ]. Tostring ());
LBN. postbackurl = Surl;
//Add controls
Htctd. Controls. Add (LBN );
Htrtr. cells. Add (htctd );
Httab. Rows. Add (htrtr );
If (Irow % 2 = 0 )
{
Htrtr = New Htmltablerow ();
}
}
Phcontrol. Controls. Add (httab );
}
}