scropio gurl

scropio gurl

  • NA
  • 147
  • 96.8k

Insert label value in table

Oct 24 2016 5:20 AM
There is dropdown in abc page and values
323r
244f
 
and there is button and table
 
TID TTID
1    323r
2    244f
 
so when i select value from dropdown and click on button then value is save in table
 
and after this there is def page
in that there is label i save dropdown selected value in label  
 
there is another table 2
 
in that
 
id TTID value3
1  323r  234
2  323r  456
 
so i want when i click on button which is def page want to save label value  in TTID column in table 2
for this i try this in linq
 
  1. protected void Button2_Click(object sender, EventArgs e)  
  2.        {  
  3.            string TTID "";  
  4.   
  5.            tbl_fl_schedule ss = new tbl_fl_schedule();  
  6.            Data t = new Data();  
  7.            ss.TTID TTID ;  
  8.            {  
  9.               
  10.                ss.TTID = HttpContext.Current.Session["Vechilevalue"].ToString();  
  11.            }  
  12.   
  13.            t.tbl_fl_schedule.Add(ss).ToString();  
  14.            t.SaveChanges();  
  15.        }  
 and this show an error
System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
 
 
i want to do this through jquery
i  try this
  1. public static void insertservies(string Vechile_ID)  
  2.     {  
  3.         tbl_fl_schedule ss = new tbl_fl_schedule();  
  4.         Data t = new Data();  
  5.         ss.TTID TTID ;  
  6.         {  
  7.             //ss.Vechile_ID=  
  8.             ss.TTID  = HttpContext.Current.Session["Vechilevalue"].ToString() ;  
  9.         }  
  10.   
  11.         t.tbl_fl_Services_schedule.Add(ss).ToString();  
  12.         t.SaveChanges();  
  13.     }  
 
  1. <script type="text/javascript">  
  2.         $(function () {  
  3.             debugger;  
  4.             $('[ID*=btnadd]').on('click', function () {  
  5.   
  6.                 var TTID '<%=Session["Vechilevalue"]%>';  
  7.   
  8.                 //var Frequency = $('#txt_repeat').val();  
  9.                 var obj = {};  
  10.                 obj.TTID TTID ;  
  11.   
  12.                 get(obj);  
  13.             });  
  14.         });  
  15.   
  16.             function get(obj) {  
  17.                 debugger;  
  18.                 var ins = {};  
  19.                 ins.Vechile_ID = obj.Vechile_ID;  
  20.   
  21.                 $.ajax({  
  22.                     type: "POST",  
  23.                     url: "Maintenance.aspx/insertservies",  
  24.                     contentType: "application/json;charset=utf-8",  
  25.                     data:JSON.stringify(ins),  
  26.                     dataType: "json",  
  27.                     success: function (result) {  
  28.                         debugger;  
  29.                         //("#Label1") = obj.Vechile_ID;  
  30.                        // $("#Label1" + obj.Vechile_ID).html(ins.Vechile_ID);  
  31.   
  32.                     },  
  33.                     error:function(error)  
  34.                     {  
  35.                         var r = error.responseText;  
  36.                         var errorMessage = r.Message;  
  37.                          alert(errorMessage);  
  38.                         alert(r);  
  39.                         alert("error");  
  40.   
  41.                     }  
  42.   
  43.                 });  
  44.             };  
  45.          
  46.           
  47.     </script>  
 but this is also not working

Answers (1)