Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
Checking checkboxes in WebDataGrid placed in a ModalPopupExtender makes button events not fire.
posted

I have a user control that uses ModalPopupExtender. Inside the user control, there are 2 buttons and a WebDataGrid. First column in the grid is an UnboundCheckBoxField.

When the popup comes up, displays the grid with data, I can use either of the buttons to hide the popup. The second that any row is checked (with checkboxes), the popup does not close on button clicks anymore. I have a server side event for the button "confirm" and it does not fire if a single row in the grid is checked. I noticed however that it's fine and still works if ALL or NO rows are checked. Clueless as to why that would be happening.

If a checkbox or multiple checkboxes are checked, the server side events for buttons do not fire anymore. If ALL checkboxes are checked or none, they fire fine.

Pic

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="EmployeeSelector.ascx.vb" Inherits="EmployeeSelector" %>

<%@ Register Assembly="Infragistics4.Web.v14.1, Version=14.1.20141.2392, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB" Namespace="Infragistics.Web.UI.GridControls" TagPrefix="ig" %>

<%@ Register Assembly="Infragistics4.WebUI.Misc.v14.1, Version=14.1.20141.2392, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB" Namespace="Infragistics.WebUI.Misc" TagPrefix="igmisc" %>

<style type="text/css">

    .modalBackground {

   background-color:#000000;

   filter:alpha(opacity=80);

   opacity:0.8;

   }

   .modalPopup

   {

   position:fixed;

   border-radius:5px;

   top:10%;

   left:10px;

   width:700px;

   height:400px;

   text-align:center;

   background-color:White;

   color:black;

   }

</style>

<ajax:ModalPopupExtender ID="popup" runat="server" DropShadow="false" PopupControlID="pnlPopup" TargetControlID="lnkFake" BackgroundCssClass="modalBackground"></ajax:ModalPopupExtender>

<asp:Panel ID="pnlPopup" runat="server" CssClass="modalPopup">

    <table>

        <tr>

            <td>

                <table>

                    <tr>

                        <td>

                            <asp:Button ID="btnClose" runat="server" CssClass="btn btn-xs btn-primary" OnClientClick="return Hidepopup()" Text="Close" />

                        </td>

                        <td>

                            <asp:Button ID="btnConfirm" runat="server" CssClass="btn btn-xs btn-primary" Text="Confirm" />

                        </td>

                    </tr>

                </table>

            </td>

        </tr>

        <tr>

            <td>

                <table style="width: 700px">

                    <tr>

                        <td style="width: 70%; height: 300px">

                            <ig:WebDataGrid ID="dgv" AutoGenerateColumns="false" HeaderCaptionCssClass="InfraGridHead_XS" EnableAjax="false" Height="100%" Width="100%" runat="server">

                                <Behaviors>

                                    <ig:Activation Enabled="true"></ig:Activation>

                                    <ig:EditingCore BatchUpdating="true">

                                        <Behaviors>

                                            <ig:CellEditing>

                                                <EditModeActions MouseClick="Single" EnableOnActive="true" />

                                                <ColumnSettings>

                                                    <ig:EditingColumnSetting ColumnKey="Code" ReadOnly="true" />

                                                    <ig:EditingColumnSetting ColumnKey="FullName" ReadOnly="true" />

                                                    <ig:EditingColumnSetting ColumnKey="SquadCode" ReadOnly="true" />

                                                    <ig:EditingColumnSetting ColumnKey="RankCode" ReadOnly="true" />

                                                </ColumnSettings>

                                            </ig:CellEditing>

                                        </Behaviors>

                                    </ig:EditingCore>

                                </Behaviors>

                            </ig:WebDataGrid>

                        </td>

                    </tr>

                </table>

            </td>

        </tr>

    </table>

</asp:Panel>

<asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>

And here's the VB code:

Imports VCS.Database.Access.MSSQL

 

Partial Class EmployeeSelector

    Inherits System.Web.UI.UserControl

 

    Public Event Confirm()

 

    Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        If Not IsPostBack Then

            configGrid()

        End If

 

        LoadEmployees()

    End Sub

 

    Private Sub LoadEmployees()

        Dim emps = EmployeeDao.LoadAllEmployees.OrderBy(Function(x) x.LastName).ToList

        dgv.DataSource = emps

        dgv.DataBind()

    End Sub

 

    Public Sub Show()

        popup.Show()

    End Sub

 

    Protected Sub btnConfirm_Click(sender As Object, e As EventArgs) Handles btnConfirm.Click

        RaiseEvent Confirm()

    End Sub

 

    Private Sub configGrid()

        dgv.AutoGenerateColumns = False

 

        Dim chk As New Infragistics.Web.UI.GridControls.UnboundCheckBoxField

        chk.Key = "Checked"

        chk.Header.Text = ""

        chk.Hidden = False

        chk.Width = 30

        dgv.Columns.Add(chk)

 

        Dim col As New Infragistics.Web.UI.GridControls.BoundDataField

        col = New Infragistics.Web.UI.GridControls.BoundDataField

        col.DataFieldName = "Code"

        col.Key = "Code"

        col.Header.Text = "Code"

        col.Hidden = False

        dgv.Columns.Add(col)

 

        col = New Infragistics.Web.UI.GridControls.BoundDataField

        col.DataFieldName = "FullName"

        col.Key = "FullName"

        col.Header.Text = "Name"

        col.Hidden = False

        dgv.Columns.Add(col)

 

        col = New Infragistics.Web.UI.GridControls.BoundDataField

        col.DataFieldName = "RankCode"

        col.Key = "RankCode"

        col.Header.Text = "Title"

        col.Hidden = False

        dgv.Columns.Add(col)

 

        col = New Infragistics.Web.UI.GridControls.BoundDataField

        col.DataFieldName = "SquadCode"

        col.Key = "SquadCode"

        col.Header.Text = "Group"

        col.Hidden = False

        dgv.Columns.Add(col)

    End Sub

 

End Class

 

Parents
  • 150
    Verified Answer
    posted

    Found the solution. Apparently I was missing DataKeyFields property on the grid. I'm guessing that made checking the checkboxes in the grid not know which unique rows are checked.

Reply Children
No Data