Code
Front-end:
< ASP: Panel ID = " Pnlcondition " Runat = " Server " Width = " 100% " >
</ ASP: Panel >
Background: literalcontrol LC= Null;
Dropdownlist DDL= Null;
Label LBL= Null;
Textbox txt= Null;//Global
// Load
Datatable dtkeyinfo = DB. executedataset (dc). Tables [ 0 ]; // Get the definition of each column in the configuration table
LC = New Literalcontrol ( " <Table> " );
Pnlcondition. Controls. Add (LC );
For ( Int I = 0 ; I < Dtkeyinfo. Rows. Count; I ++ )
{
LC = New Literalcontrol ( " <Tr> " );
Pnlcondition. Controls. Add (LC );
LC = New Literalcontrol ( " <TD class = 'field _ label'> " );
Pnlcondition. Controls. Add (LC );
LBL = New Label ();
LBL. ID = I. tostring ();
LBL. Text = Dtkeyinfo. Rows [I] [ " Fieldname " ]. Tostring ();
Pnlcondition. Controls. Add (LBL );
LC = New Literalcontrol ( " </TD> " );
Pnlcondition. Controls. Add (LC );
LC = New Literalcontrol ( " <TD> " );
Pnlcondition. Controls. Add (LC );
String Column = Dtkeyinfo. Rows [I] [ " Fieldname " ]. Tostring ();
If (Dtkeyinfo. Rows [I] [ " Uitype " ]. Tostring () = " DDL " )
{
DDL = New Dropdownlist ();
DDL. ID = Column;
This . Bindddl (DDL, column );
Pnlcondition. Controls. Add (DDL );
}
If (Dtkeyinfo. Rows [I] [ " Uitype " ]. Tostring () = " Txt " )
{
Txt = New Textbox ();
TXT. ID = Column;
TXT. maxlength = 10 ;
Pnlcondition. Controls. Add (txt );
}
LC = New Literalcontrol ( " </TD> " );
Pnlcondition. Controls. Add (LC );
LC = New Literalcontrol ( " </Tr> " );
Pnlcondition. Controls. Add (LC );
}
LC = New Literalcontrol ( " </Table> " );
Pnlcondition. Controls. Add (LC );