473,466 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

search, edit and postback

Hi,
I have an Employerregistration pagethat is used to add new Empoyers
to a table. I also have another form search.aspx used to search the
employers(based on their id) and edit the employer details.

My question what is the best way to accept the search criteria and
pass to the Employerregistration page (assuming only a sigle record is
returned). Currently I store the search criteria in the
SearchForm.aspx.cs class and define a get method for it. I declare a
variable of type searchform in the Employerregistration and access the
search criteria.

Also what exactly is a postback ? I have read several definitions but
I still don't get it.

Is this the best way to code your Page_Load when you want to edit a
single record?

thanks,

Arun

public class SearchForm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox searchCriteria;
protected System.Web.UI.WebControls.Button btnSearch;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

public String SearchCriteria
{
get { return searchCriteria.Text; }
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSearch.Click += new
System.EventHandler(this.btnSearch_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

private void btnSearch_Click(object sender, System.EventArgs e)
{
// Session["searchCritera"] = searchCriteria.Text;
Server.Transfer("./EmployerForm.aspx");
}
}

My Page_Load of the EmployerForm looks like this:
public class EmployerForm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox eeno;
protected System.Web.UI.WebControls.RadioButton Organization;
protected System.Web.UI.WebControls.RadioButton Individual;
protected System.Web.UI.WebControls.TextBox employerName;
protected System.Web.UI.WebControls.TextBox contactPerson;
protected System.Web.UI.WebControls.TextBox houseNo;
protected System.Web.UI.WebControls.TextBox street;
protected System.Web.UI.WebControls.Button btnSave;
public SearchForm sf;
private void Page_Load(object sender, System.EventArgs e)
{

sf = (SearchForm)Context.Handler;
// if(IsPostBack) {
SqlConnection conn;
SqlCommand comm;
DataSet ds = new DataSet();
SqlDataAdapter adapter;
string crit = sf.SearchCriteria;
conn = new SqlConnection("Server=sark011Test;uid=sa;pwd=sates t;Initial
Catalog=empexchange");
// conn.Open();

// comm = new SqlCommand("select employer_id from employer",
conn);
// adapter = new SqlDataAdapter(comm);
// adapter.Fill(ds);
// // eeno.Text = (string) ds.Tables[0].Rows[0]["employer_id"];
eeno.Text = crit;
// conn.Close();
// }
}
Nov 18 '05 #1
0 1029

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave | last post by:
Hi, I'm building a maintenance form for a table and some of the fields are textboxes (i.e name) and some should be dropdowns (i.e country of origin) When a user clicks 'Edit' in the...
4
by: rkbnair | last post by:
Is there any way to display an image button instead of the traditional Edit/Update/Cancel push button in a datagrid (with bound data)?
1
by: Ann | last post by:
Hi, I have a datagrid contained textbox in the template column. I want to create a button on each row, when a user hits the button the textbox on column of the datagrid is enabled (no...
1
by: Randall Parker | last post by:
Currently in an asp:DataGrid I have a column for bringing up an edit form on a particular row and that is done by a hyperlink as follows: <asp:TemplateColumn HeaderText="Edit Record">...
0
by: den 2005 | last post by:
Hi everybody, I am not familiar using Gridview, I created a Gridview with Edit Command Button, but when I click the update Command button this error message below is displayed, what and where is...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
4
by: bendlam | last post by:
I have a page that contains search criteria and when you click on the search button it causes a post back that populates a dataview on the same page. One of the gridview columns contains a link...
3
by: Joey | last post by:
asp.net 2.0 VS2005 C# In my web app I added a gridview and then manually configured boundcolumns, for an in-session dataset to act as a datasource. Then I added an Edit commandfield. When I...
2
by: slinky | last post by:
I had a successfully deployed datagrid reading an XML file and showing the data: Private Function MakeDataView() as DataView Dim myDataSet As New DataSet()...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.