Jagjit Saini

Jagjit Saini

  • NA
  • 196
  • 37.9k

hdfDeleteID showing wrong value

Apr 1 2022 3:35 PM

Hi

In Javascript it shows proper hdfdeleteID value , But in lnkRecordDelete_Click it shows "0"

<script type="text/javascript">
    function BindData(e) {

        var currentRow = $(e).closest("tr");

        var id = currentRow.find("td:eq(0)").text();
        var a = currentRow.find("td:eq(1)").text();

        document.getElementById('hdfID').value = id
        document.getElementById('ddlBook').value = a;

        alert(id);
        debug();
        document.getElementById('hdfDeleteID').value = id;
        document.getElementById('<%=ltrlDelHead.ClientID%>').innerHTML = "You are about to Delete the Record, Enter Delete Reason";
    };

</script>
protected void lnkRecordDelete_Click(object sender, EventArgs e)
{
    string data = "";
    try
    {
        if (hdfDeleteID.Value != "0")
        {
            BALBookModuleList bALBookModuleList = new BALBookModuleList();
            BookModule RecDel = bALBookModuleList.GetBookModuleById(Convert.ToInt32(hdfDeleteID.Value));

            RecDel.InActiveReason = txtDeleteReason.Text.Trim();
            RecDel.IsActive = false;

            int Res = bALBookModuleList.UpdateBookModule(RecDel);
            if (Res != 0)
            {
                ShowMessage("", "Record Deleted Successfully", "success");
                GetData();
            }
            else
            {
                ShowMessage("Error", "Record Delete Failed, Please Try Again", "error");
                GetData();
            }
        }
        else
        {
            ShowMessage("Error", "Record Delete Failed, Please Try Again", "error");
            GetData();
        }

        txtDeleteReason.Text = "";
    }
    catch (Exception ex)
    {
        Utility.SaveErrorLog(ex.Message, System.IO.Path.GetFileName(Request.Path), System.Reflection.MethodBase.GetCurrentMethod().Name, Convert.ToInt32(hdfLoginCode.Value), data);
        ShowMessage("Oops...", ex.Message, "error");
        GetData();
     }
}

Thanks


Answers (4)