TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ayush Patil
NA
178
20.3k
Display Excel data into HTML table in MVC using Oledb
Jun 24 2018 11:04 AM
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 =
"<tr>"
+
"<td>"
+ data.jsDiscoundGridList[0][
"New upto 3 Yrs"
] +
"</td>"
+
"<td>"
+ data.jsDiscoundGridList[0][
"Above 3 yr to 9 yrs"
] +
"</td>"
+
"<td>"
+ data.jsDiscoundGridList[0][
"Above 9 yrs upto 12 yrs"
] +
"</td>"
+
"</tr>"
;
$(
'.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)/Rolloverst
</
label
>
</
center
>
<
thead
>
<
tr
>
<
th
>
<
center
>
New upto 3 Yrs
</
center
>
</
th
>
<
th
>
<
center
>
Above 3 yr to 9 yrs
</
center
>
</
th
>
<
th
>
<
center
>
Above 9 yrs upto 12 yrs
</
center
>
</
th
>
</
tr
>
</
thead
>
<
tbody
class
=
"tbody"
>
</
tbody
>
</
table
>
</
div
>
<
br
/>
<
br
/>
</
div
>
Reply
Answers (
1
)
How Composition relation be developed beween Student Course.
SQL Query for union all the months