Issue
I have encountered a problem concerning element "asp:datagrid".
For example, i have declared a datagrid in my servlet, and set AllowSorting="True"
And i have a button, say "button1", to update data to the database base on the selected record of the datagrid.
May i ask if i can DISABLE "button1" (which is before postback of the servlet, disabled immediately after user click one of the header of the datagrid for sorting), to prevent user to commit update to the database ?
And also can i DISABLE SORTING action of the datagrid (also before postback) when "button1" was clicked ?
Thanks a lot.
Solution
You can also enable/disable controls and events programmatically. So in the sort method add this to disable sorting after the first click.
DataGrid1.AllowSorting = false;
To disable controls
Button1.Enabled = false;
To disable using a jQuery listener. You can disable the sorting links the easiest by binding a listener to the class, in this case SortingLink
<script type="text/javascript">
$('#<%= Button1.ClientID %>').click(function () {
$(this).prop('disabled', true);
});
$('#<%= GridView1.ClientID %> .SortingLink').click(function () {
$(this).prop('disabled', true);
});
</script>
Answered By - VDWWD
Answer Checked By - Clifford M. (JavaFixing Volunteer)