State Entry
State Entry
WebControls; public partial class Admin_Default : System.Web.UI.Page { Class1 ob = new Class1(); protected void Page_Load(object sender, EventArgs e) { ob.conn(); if (!IsPostBack) { clear(); } } public void clear() { txtstid.Text = autoid().ToString(); txtstid.ReadOnly = true; txtstname.Focus(); txtstname.Text = ""; } static int id; public int autoid() { ob.fetch("select stateid from state order by stateid"); if (ob.ds.Tables[0].Rows.Count == 0) { id = 1; return id; } else { id = Convert.ToInt32(ob.ds.Tables[0].Rows[ob.ds.Tables[0].Rows.Count 1].ItemArray[0].ToString()) + 1;
return id; } } protected void Button1_Click(object sender, EventArgs e) { if (txtstid.Text == "") { Label5.Text = "*"; lbl2.Text = "state id required"; txtstid.Focus(); return; } if (txtstname.Text == "") { Label6.Text = "*"; lbl2.Text = "state name should not Be Blank"; txtstname.Focus(); return; } if (ob.dml_stmt("insert into state values('" + txtstid.Text.Trim() + "','" + txtstname.Text.Trim() + "')") > 0) { lbl2.Text = "Data Inserted Successfully"; clear(); } } }