arroving documents in asp.net using stroe procedures

Posted by Diyaayeshaa under ASP.NET on 9/30/2013 | Points: 10 | Views : 1491 | Status : [Member] | Replies : 5
i try to approved documents here is code

protected void GrdFileApprove_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "_Approve")
{
//using (SqlConnection con = DataAccess.GetConnected())
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mydms"].ConnectionString))
{
try
{
int rowindex = Convert.ToInt32(e.CommandArgument);
GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
LinkButton Prove_Button = (LinkButton)row.FindControl("BtnApprove");
SqlCommand cmd = new SqlCommand("spinsertapprove", con);
cmd.CommandType = CommandType.StoredProcedure;
int result = cmd.ExecuteNonQuery();
if (result != 0)
{
GrdFileApprove.DataBind();
}
}

catch (Exception ex)
{
}
finally
{
con.Close();
}
}
}

else if (e.CommandName == "_Reject")
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mydms"].ConnectionString))
{
try
{
int rowindex = Convert.ToInt32(e.CommandArgument);
GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
LinkButton Prove_Button = (LinkButton)row.FindControl("Button1");
SqlCommand cmd = new SqlCommand("sprejectapprove", con);
cmd.CommandType = CommandType.StoredProcedure;
int result = cmd.ExecuteNonQuery();
if (result != 0)
{
GrdFileApprove.DataBind();
}
}

catch (Exception ex)
{
}
finally
{
con.Close();
}
}



here is query
create procedure sprejectapprove
@UserID int,
@DocID int,
@ApproveType nvarchar(50)
as
Insert into Approval(UserID,DocID,ApproveType)
values(@UserID,@DocID,@ApproveType)



create procedure spinsertapprove
@UserID int,
@DocID int,
@ApproveType nvarchar(50)
as
Insert into Approval(UserID,DocID,ApproveType)
values(@UserID,@DocID,@ApproveType)




when i debug the code and click an approve button there is not any responce .....and any data not goes to database
in database i have a seprate approval table in which
userid,docid,approve type columns invlove

please help




Responses

Posted by: Bandi on: 9/30/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
run above task in button click event....
or check whether you have that event handler in gridview design

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Diyaayeshaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/30/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
the reasons behind event not getting fired is:
http://www.codeproject.com/Questions/224082/gridview-not-firing-row-command-event
http://stackoverflow.com/questions/8494730/gridview-rowcommand-event-not-firing
http://bytes.com/topic/asp-net/answers/521156-gridview-rowcommand-event-not-firing
http://bytes.com/topic/asp-net/answers/521156-gridview-rowcommand-event-not-firing



Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Diyaayeshaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Diyaayeshaa on: 9/30/2013 [Member] Starter | Points: 25

Up
0
Down
how i run in buttn click event?

and the links doesn't work for me :(

Diyaayeshaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/30/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
can you post us back the gridview deaigb which you have now?


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Diyaayeshaa, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 10/1/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
You have forgot to add the below statement.

cmd.Parameters.AddWithValue("@UserID", UserIdValue);
cmd.Parameters.AddWithValue("@DocID", DocIDValue);
cmd.Parameters.AddWithValue("@ApproveType", ApproveTypeValue);


Happy Coding,
If it helps you or directs U towards the solution, MARK IT AS ANSWER

Diyaayeshaa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response