Thanks..but already i have implement like your code in DataAccessLaye[UsermanagerDataAccess] i need call this Function in my button click event for insert
protected void YourButtonIdName_Click(object sender, EventArgs e)
{
Your code to insert data
}
You can also get this by double clicking your button. When you dblclick your button it will open .cs file with clickevent as i mentioned.
I know how it is call button event and think so...but here i have built code in Data Access layer for Connection oriented,,,and also in that i have build code for insert in this only...no in codebehind file...if we will implement in cs file it will be lengthy...we
are using oops...so everything is object and we can call anything within ap/n...so how i call from Data access file to my submit button...
inguru
Member
310 Points
257 Posts
Aspx.cs file button click event for insert data
Aug 18, 2012 05:45 AM|LINK
Dear friends,
I have one webpage...and it has using for this DataObject,validation and also Data access...in data access using stored procedur for insert data...
within button event
UserManagementDO objUSRDO = new UserManagementDO();
i need now in cs file..if i click submit button it will store in DB...please give solution to me
Keyur Shah
Participant
1002 Points
278 Posts
Re: Aspx.cs file button click event for insert data
Aug 18, 2012 05:54 AM|LINK
This may help you.
protected void btnSave_Click(object sender, EventArgs e) { con.Open(); cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "InsertDesig"; cmd.Parameters.AddWithValue("@EmpId", txtEmpId.Text.Trim()); cmd.Parameters.AddWithValue("@EmpName", txtEmpName.Text.Trim()); cmd.Parameters.AddWithValue("@EmpDOJ", txtEmpDOJ.Text.Trim()); cmd.Parameters.AddWithValue("@EmpDesig", txtEmpDes.Text.Trim()); cmd.Connection = con; cmd.ExecuteNonQuery(); cmd.Dispose(); con.Close(); }If any query is there you can ask.
inguru
Member
310 Points
257 Posts
Re: Aspx.cs file button click event for insert data
Aug 18, 2012 07:02 AM|LINK
Thanks..but already i have implement like your code in DataAccessLaye[UsermanagerDataAccess] i need call this Function in my button click event for insert
inguru
Member
310 Points
257 Posts
Re: Aspx.cs file button click event for insert data
Aug 18, 2012 07:17 AM|LINK
Dear Mr.Sha my code is in my DataAccess layer using below like this...i want to call this in submit button_click_event
how can i do
public int Adduser(UserManagerDO ObjDMDO) { int returnValue = 0; SqlCommand insertCommand = new SqlCommand(); insertCommand.CommandText = "USP_Insertuser"; insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.Connection = _connectionObject; insertCommand.Parameters.Add(new SqlParameter("@UserID",ObjDMDO.UserID)); insertCommand.Parameters.Add(new SqlParameter("@UserName",ObjDMDO.DealerName)); try { _connectionObject.Open(); returnValue = Convert.ToInt32(insertCommand.ExecuteNonQuery()); } catch (Exception exception) { if (_connectionObject.State == ConnectionState.Open) { _connectionObject.Close(); } throw exception; } if (_connectionObject.State == ConnectionState.Open) { _connectionObject.Close(); } return returnValue; }Keyur Shah
Participant
1002 Points
278 Posts
Re: Aspx.cs file button click event for insert data
Aug 18, 2012 07:27 AM|LINK
protected void YourButtonIdName_Click(object sender, EventArgs e) { Your code to insert data } You can also get this by double clicking your button. When you dblclick your button it will open .cs file with clickevent as i mentioned.inguru
Member
310 Points
257 Posts
Re: Aspx.cs file button click event for insert data
Aug 18, 2012 08:46 AM|LINK
I know how it is call button event and think so...but here i have built code in Data Access layer for Connection oriented,,,and also in that i have build code for insert in this only...no in codebehind file...if we will implement in cs file it will be lengthy...we are using oops...so everything is object and we can call anything within ap/n...so how i call from Data access file to my submit button...
Keyur Shah
Participant
1002 Points
278 Posts
Re: Aspx.cs file button click event for insert data
Aug 18, 2012 08:50 AM|LINK
Sorry. I didn't applied this. So i have no idea.
But i am searching for this. I'll let you know soon.
GaurangNaik
Contributor
2095 Points
499 Posts
Re: Aspx.cs file button click event for insert data
Aug 18, 2012 10:48 AM|LINK
Hi,
If you have implemeted this in a class then then you can create an object of that class on the button click event and call the method.
GauranG