You must Sign In to post a response.
  • Category: Silverlight

    Datagrid checkbox check/uncheck

    Hi ,

    I have two rows binded to datagrid in silverlight. First column is checkbox.
    If I am selecting one checkbox then other should get unchek. how to chieve this.



    Regards,
    Ayesha
  • #753471
    Hi,

    If you want to Toogle checkbox selection of gridview control then use below sample code and refer that and implement in your application.


    <script type="text/javascript" language="javascript">

    function CheckGrid(source) {
    var isChecked = source.checked;
    $("#chkGrid input[id*='chkSelect']").each(function (index) {
    $(this).attr('checked', false);
    });
    source.checked = isChecked;

    }

    </script>


    <asp:TemplateField HeaderText="Check">
    <ItemTemplate>
    <asp:CheckBox ID="chkSelect" runat="server" onclick="CheckGrid(this);" />
    </ItemTemplate>
    </asp:TemplateField>



    Refer below link for more details.

    http://www.dotnetspider.com/resources/45865-Toggle-Selection-Checkbox-inside-Grid-View.aspx

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #753481
    You can create a method where you can pass the current row to skip



    rivate void DisableCheckboxColumnInRow(DataGridRow row)
    {
    var checkBoxColumn = Datagrid1.Columns[0];
    var checkBoxCell = GetCell(checkBoxColumn, row);
    checkBoxCell.IsEnabled = false;
    }

    private static DataGridCell GetCell(DataGridColumn column, DataGridRow row)
    {
    var cellContent = column.GetCellContent(row);
    return (DataGridCell)cellContent.Parent;
    }

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #753498
    Hi,
    Here you go with the sample code and detailed explanation to accomplish this task.
    msdn.microsoft.com/en-us/library/cc221404(v=vs.95).aspx
    java2s.com/Code/Silverlight/UI-Controls/CheckifaCheckBoxischecked.htm
    Let me know if this doesn't help or yyou require any other information related this query.


    Regards,
    Asheej T K


  • Sign In to post your comments