Click here to Skip to main content
15,885,936 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I have Dropdown & button in Gridview Row.

I would like to select one item from drop down. & fixed it on row button click.

Which i have already done.By using RowCommand Event.

But

prior to that it need to give alert message on button click.

alert should be "Are you sure to proceed?"

If I click yes then Proceed otherwise exit from command.

Thanking You in Advance.


code is here...

VB
Private Sub JsAjaxWrite()
        ScriptManager.RegisterStartupScript(Page, [GetType], "Key", jsScr, True)
End Sub



Protected Sub gvAssignmentSummuryAS_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvAssignmentSummuryAS.RowCommand
        Try
            'Find the row index of from where commnad has initiated to view the employee detail.
            Dim i As Integer = Convert.ToInt32(e.CommandArgument)
            'Find the control dropdown from gridview & set same in new control
            Dim cboEmployeeNo As DropDownList = DirectCast(gvAssignmentSummuryAS.Rows(i).FindControl("cboEmployeeNo"), DropDownList)

            If e.CommandName = "Assign" Then
                If cboEmployeeNo.SelectedIndex = 0 Then     'If no value selected in dropdown then give alert.
                    jsScr = jsScr & "alert('Select Project Member to Assign.');"
                    JsAjaxWrite()
                    Exit Sub
                End If

                Dim rolecode As String = Convert.ToString(gvAssignmentSummuryAS.Rows(i).Cells(1).Text)
                'txtDummyDepIdAS.Text = ("UPDATE ESUPPORT_MPA_ALLOCATION SET ALLO_EMP_CODE = " & cboEmployeeNo.SelectedValue & " WHERE ALLO_ROLE_CODE||0||ALLO_ROLE_SR_NO = '" & rolecode & "' AND ALLO_PROJ_JOB_CODE=" & cboProjCodeAS.SelectedValue & " AND ALLO_DEPT_CODE =" & cboDepartmentAS.SelectedValue & "")
                If sei_helper.ExecuteNonquery("UPDATE ESUPPORT_MPA_ALLOCATION SET ALLO_EMP_CODE = " & cboEmployeeNo.SelectedValue & " WHERE ALLO_ROLE_CODE||0||ALLO_ROLE_SR_NO = '" & rolecode & "' AND ALLO_PROJ_JOB_CODE=" & cboProjCodeAS.SelectedValue & " AND ALLO_DEPT_CODE =" & cboDepartmentAS.SelectedValue & "") = 1 Then
                    jsScr = jsScr & "alert('Employee Assignment done successfully');"
                    JsAjaxWrite()
                End If


            If sei_helper.strErr <> "N" Then
                ErrHnd()
            End If
        Catch ex As Exception
            MessageBox(ex.Message)
        End Try
    End Sub
Posted
Updated 21-Nov-13 20:36pm
v6
Comments
Nandakishore G N 18-Oct-13 6:18am    
what have you done till now paste it?.
because it can be achieved by both jquery and code behind.
Mahesh Devikar 18-Oct-13 7:23am    
I have posted my code.If Possible tell me Code Behind Method.

this is enough i think,

 &lt;asp:TemplateField HeaderText="DELETE" HeaderStyle-BackColor="#8d3736"  HeaderStyle-CssClass="gridheader"&gt;
                                &lt;ItemTemplate&gt;
                                    &lt;asp:ImageButton ID="ImageButton8" runat="server" CommandName="del" 
                                        ImageUrl="~/Images/delete.png" 
                                       <big> onclientclick="return confirm('Do You Want To Delete?')"</big> 
                                        onclick="ImageButton8_Click" /&gt;
                                &lt;/ItemTemplate&gt;

&lt;HeaderStyle BackColor="#8D3736" CssClass="gridheader"&gt;&lt;/HeaderStyle&gt;
                            &lt;/asp:TemplateField&gt;
 
Share this answer
 
v5
C#
using System.Windows.Forms;

dynamic result = MessageBox.Show("Are You Want To Cancle", "Your Website Name", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

       
         if (result == DialogResult.No)
        {
            
        }
        else if (result == DialogResult.Yes)
        {
            Response.Redirect("");
        }
 
Share this answer
 
v2
Comments
Mahesh Devikar 22-Nov-13 2:34am    
See its not working. It is not taking Dynamic.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900