now i set insert query and reject query like this

ALTER procedure [dbo].[sprejectapprove]
@UserID int,
@DocID int,
@ApproveType nvarchar(50)
as
Insert into Approval(UserID,DocID,ApproveType)
values(@UserID,@DocID,@ApproveType)

Reject

ALTER procedure [dbo].[spinsertapprove]
@UserID int,
@DocID int,
@ApproveType nvarchar(50)
as
Insert into Approval(UserID,DocID,ApproveType)
values(@UserID,@DocID,@ApproveType)

and i call this sp's in this codes

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 
                    {
                        apfi.Text = "Not Approve";



                    }
                    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 
                    {
                        apfi.Text = "Rejct";
                    }
                    finally
                    {
                        con.Close();
                    }
                }
            }

then when i beugh the code and click on approve this can not give me any responce

grdiview

<center><div class="vpb_main_wrapper2" top=20 align="center" style="left: inherit"/><br clear="all"/>
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server"/>
             <asp:UpdatePanel runat="server" ID="UPanle"
                ondatabinding="UPanle_DataBinding_Click">
                <ContentTemplate>
               <asp:GridView ID="GrdFileApprove" runat="server" AutoGenerateColumns="false"
                    onrowcommand="GrdFileApprove_RowCommand"
    onselectedindexchanged="GrdFileApprove_SelectedIndexChanged">
                   <Columns>
                       <asp:TemplateField HeaderText="S no">
                           <ItemTemplate>
                               <%# Container.DataItemIndex+1 %>
                               <asp:HiddenField runat="server" ID="HdnFileID" Value='<%# Eval("DocID") %>' />
                           </ItemTemplate>
                       </asp:TemplateField>
                       <asp:BoundField DataField="DocID" HeaderText="DocumentID"  />
                       <asp:BoundField DataField="DocName" HeaderText="DocName"  />
                       <asp:BoundField DataField="Uploadfile" HeaderText="File Name" />
                       <asp:BoundField DataField="DocType" HeaderText="Document" />
                       <asp:BoundField DataField="DepType" HeaderText="Department" />
                       <asp:TemplateField HeaderText="S no">
                           <ItemTemplate>
                               <asp:Button runat="server" Id="BtnApprove" CommandName="_Approve"
                                    CommandArgument='<%# Eval("DocID") %>' Text="Aprrove" />
                               <asp:Button runat="server" Id="Button1" CommandName="_Reject"
                                    CommandArgument='<%# Eval("DocID") %>' Text="Reject" />
                           </ItemTemplate>
                       </asp:TemplateField>
                   </Columns>
               </asp:GridView>
           </ContentTemplate>


            </asp:UpdatePanel>

    </div>
        <asp:Label ID="apfi" runat="server" Text="Label"></asp:Label>

    </center>
    </div>

Recommended Answers

All 2 Replies

What do you mean by no response? something should be happending somewhere...

try putting in some additional events in your code that you can use to troubleshoot the issue, or remove the try..catch blocks so that you can actually see the error your code is generating.

Is there a click event on the button?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.