|
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ganesh;
namespace MyAjaxSample
{
public partial class Testing : System.Web.UI.Page
{
public static string connectionString = (string)ConfigurationManager.AppSettings["ConnectionString"];
public DataSet ds = new DataSet();
DBClass MyClass = new DBClass();
public SqlDataAdapter ObjSDA;
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(Testing));
if (!IsPostBack)
{
DropDownList1.DataSource = MyClass.GetDataSet("Select * from Testing");
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "ID";
DropDownList1.DataBind();
DropDownList1.Items.Add("--Select table--");
DropDownList1.SelectedIndex = DropDownList1.Items.Count - 1;
}
}
[AjaxPro.AjaxMethod]
public DataSet Inserting(string Name)
{
SqlConnection myConnection = new SqlConnection(connectionString);
string strQuery = "Insert into Testing Values('" + Name + "')";
int res = MyClass.ExecuteQry(strQuery);
ObjSDA = new SqlDataAdapter("Select * from Testing", myConnection);
ObjSDA.Fill(ds);
return ds;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.