Using system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Namespace testwebservice
{
/// <Summary>
/// Summary of webform1.
/// </Summary>
Public class webform1: system. Web. UI. Page
{
Protected system. Web. UI. webcontrols. Button button1;
Protected system. Web. UI. webcontrols. textbox textbox1;
Protected system. Web. UI. webcontrols. textbox textbox2;
Protected System. Web. UI. WebControls. TextBox TextBox3;
Protected System. Web. UI. WebControls. TextBox TextBox4;
Protected System. Web. UI. WebControls. Label Label1;
Protected System. Web. UI. WebControls. DataGrid DataGrid1;
Protected System. Web. UI. WebControls. TextBox TextBox5;
Protected System. Web. UI. WebControls. TextBox Textbox6;
Private void Page_Load (object sender, System. EventArgs e)
{
// Place user code here to initialize the page
}
# Code generated by region Web Form Designer
Override protected void OnInit (EventArgs e)
{
//
// CODEGEN: This call is required by the ASP. NET Web form designer.
//
InitializeComponent ();
Base. OnInit (e );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void InitializeComponent ()
{
This. Button1.Click + = new System. EventHandler (this. button#click );
This. Load + = new System. EventHandler (this. Page_Load );
}
# Endregion
Private void button#click (object sender, System. EventArgs e)
{
// Get the DataTable
DataTable dt = new DataTable ();
String [] aryField = {"Associate", "Fieldname", "Fileldvalue", "Operate "};
String [] aryVale = {TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text };
For (int I = 0; I <aryField. Length; I ++)
{
Dt. columns. add (new DataColumn (aryField [I], typeof (string); // set the ColumnName OF THE DataTable, and design different typeof based on different field types, it is best not to use the for loop for separate writing.
}
DataRow dr = dt. NewRow ();
For (int I = 0; I <aryField. Length; I ++)
{
Dr [aryField [I] = aryVale [I]; // you can specify the row content of a DataTable.
}
Dt. Rows. Add (dr );
// Get the DataTable end
DataGrid1.DataSource = dt;
DataGrid1.DataBind ();
Textbox6.Text = dt. Columns [0]. ColumnName;
TextBox5.Text = dt. Rows [0] ["Associate"]. ToString ();
}
}
}