0% found this document useful (0 votes)
23 views2 pages

State Entry

This document contains code for a web page that allows inserting data into a database table called "state". It includes functions to generate an auto-incrementing ID, clear form fields, validate required fields, and execute an INSERT statement to add a new record to the state table.

Uploaded by

Ashish Kumar Lal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

State Entry

This document contains code for a web page that allows inserting data into a database table called "state". It includes functions to generate an auto-incrementing ID, clear form fields, validate required fields, and execute an INSERT statement to add a new record to the state table.

Uploaded by

Ashish Kumar Lal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.

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(); } } }

You might also like