Here I am trying to get the value into HTML Table using OLEDB Connection. but I am getting the value in table as undefined please give me a solution to show excel data
Controller Code:
- if (objMotorUnderwritingList.ddlVehicleType == "TW$")
- {
- cmd.Connection = objConn;
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = "SELECT [New upto 3 Yrs],[Above 3 yr to 9 yrs],[Above 9 yrs upto 12 yrs] FROM [" + objMotorUnderwritingList.ddlVehicleType + "] where [ZONE]= '" + objMotorUnderwritingList.ddlZone + "'and [STATE]='" + objMotorUnderwritingList.ddlState + "' and [Category]='" + objMotorUnderwritingList.ddlTWCategory + "'and [Make & Model]='" + objMotorUnderwritingList.ddlTWMakeModel + "'and [Cubic Capacity]='" + objMotorUnderwritingList.ddlTWCC + "' "; oleda = new OleDbDataAdapter(cmd); oleda.Fill(ds, "excelData"); dtResult = ds.Tables["excelData"]; objConn.Close(); var DiscoundList = JsonConvert.SerializeObject(dtResult, Formatting.Indented); return Json(new { jsDiscoundGridList = DiscoundList, }, JsonRequestBehavior.AllowGet);
- }
Script Code:
- success: function (data)
- {
- if (objMotorUnderwritingList.ddlVehicleType == "TW$")
- {
- if (data.jsDiscoundGridList != 0)
- {
- var eachrow = "
" + " ";" + data.jsDiscoundGridList[0]["New upto 3 Yrs"] + " " + "" + data.jsDiscoundGridList[0]["Above 3 yr to 9 yrs"] + " " + "" + data.jsDiscoundGridList[0]["Above 9 yrs upto 12 yrs"] + " " + " - $('.tbody').html(eachrow); } else { ShowAlert("Something Wrong in TW");
- }
- }
here I am getting value in DiscoundGridList as
[
{
"New upto 3 Yrs": 40.0,
"Above 3 yr to 9 yrs": 35.0,
"Above 9 yrs upto 12 yrs": 30.0
}
]
View/HTML Code:
- <div class="col-sm-12" id="divTblTW" style="display: none;"> <div class="tblContainer"> <table class="table table-striped table-bordered " id="tblTW" cellspacing="0" align="center" height="1"> <center><label class="col-sm-12 control-label">Discount % Grid For New (Fresh)/Rolloverstlabel>center> <thead> <tr> <th><center>New upto 3 Yrscenter>th> <th><center>Above 3 yr to 9 yrscenter>th> <th><center>Above 9 yrs upto 12 yrscenter>th> tr> thead> <tbody class="tbody">tbody> table> div> <br /> <br /> div>
Manav PandyaPosted Jun 25, 2018, 2:49 AM