Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when i change industry name and i click tick button the status is passing as null when i change status that industry name is passing as null why??? i use xeditable bootstrap3 plugin...plzzz help me if there is any chance to overcome this problem????

What I have tried:

View Page:
<script>
       (function ($) {
           'use strict';
           $(function () {
               if ($('#editable-form').length) {
                   $.fn.editable.defaults.mode = 'inline';
                   $.fn.editableform.buttons =
                       '<button type="submit" id="btnupdate" onclick="update()" class="btn btn-primary btn-sm editable-submit">' +
                       '' +
                       '</button>' +
                       '<button type="button" class="btn btn-warning btn-sm editable-cancel">' +
                       '^__i class="fa fa-fw fa-times">' +
                       '</button>';

                   $('#industry_name').editable({
                       inputclass: 'industry_name',
                       type: 'text',
                       pk: 1,
                       name: 'username',
                       title: 'Enter username'
                   });

                   $('#industry_status').editable({
                       inputclass: 'industry_status',
                       source: [{
                           value: 'Active',
                           text: 'Active'
                       }, {
                           value: 'Inactive',
                           text: 'Inactive'
                       }]
                   });
               }
           });
       })(jQuery);
   </script>

Onclick function for button:

<script>
        function update() {            
            var Para = $("#industry_id").val();
            var Para1 = $(".industry_name").val();
            var Para2 = $(".industry_status").val();           
            $.ajax({
                type: "POST",
                url: "/Management/Edit",
                data: { id: Para, name: Para1, status: Para2 },
                success: function (response) {
                   
                },
                error: function (response) {
                   
                }

            });
        }
Controller Page:

public ActionResult Edit(int ID, string name, string status)
        {
            mng_industrymodel model = new mng_industrymodel();
            try
            {
                if (ModelState.IsValid == true)
                {
                    string Industy_ID = Convert.ToString(ID);
                    string Industry_name = name;
                    string Industry_status = status;
                    bO_Common.industry_id = Industy_ID;
                    bO_Common.industry_name = Industry_name;
                    bO_Common.industry_status = Industry_status;
                    bO_Common.BO_Industry_Update();
                    Session["SInfoMsg"] = "Record Updated Successfully";
                    Session["SInfoMsgType"] = "SUCCESS";
                    return RedirectToAction("Industry");
                }
            }
            catch (Exception ex)
            {
                logger.write("ManagementController.cs", "ERROR ON mng_industrymodel(model) - " + ex.Message);
                model.messageinfo = CommonCls.GetMsg(ex.Message, "ERROR");
            }
            return View();
        }
Posted
Updated 15-Mar-20 19:43pm
Comments
ZurdoDev 13-Mar-20 9:56am    
Why? There is no way for us to know. I don't see code for the tick button but this is very, very simple to fix. All you have to do is debug the code. Simple. Then you'll see what is happening.
Member 14662237 14-Mar-20 1:55am    
i have fixed a issue thanku
ZurdoDev 14-Mar-20 8:43am    
Glad to hear it. Please post something as a solution so that this question no longer shows unanswered.
Member 14662237 16-Mar-20 1:40am    
kkk sir

1 solution

It's simple the above code has no error when you edit a industry name the industry status always become null bcoz you are updating the name only sooo you can use a query dynamically.use dynamic update query this will solve ur problem.

UPDATE industry_dets SET industry_name= CASE WHEN _industry_name IS NULL OR _industry_name =' ' THEN industry_name ELSE _industry_name END,
               industry_status= CASE WHEN _industry_status IS NULL OR _industry_status =' ' THEN industry_status ELSE _industry_status END 
               WHERE industry_id=_industry_id;
 
Share this answer
 

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