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
Francky Frined
NA
50
1.5k
Pls help to check why bind data to gridview no data reponse
Sep 30 2018 9:01 PM
Pls help to check why bind data to gridview no data reponse as below:-
1) WebForm3.aspx
<script type=
"text/javascript"
src=
"../js/jquery-1.3.2.min.js"
></script>
<script type=
"text/javascript"
>
$(document).ready(
function
() {
$(
'#Data'
).change(
function
() {
$.ajax({
type:
"POST"
,
contentType:
"application/json; charset=utf-8"
,
url:
"Fetch.aspx/GetData"
,
data:
"{ JO_NO: '"
+ $('#Data
').val() + "'
}",
dataType:
"json"
,
success:
function
(data) {
$(
"#DataDetails"
).html(data.d);
}
});
});
});
</script>
<form id=
"form1"
runat=
"server"
>
<div id=
"SelectData"
>
<asp:DropDownList ID=
"Data"
runat=
"server"
>
</asp:DropDownList>
</div>
<div id=
"DataDetails"
>
</div>
</form>
Code Behind
protected
void
Page_Load(
object
sender, EventArgs e)
{
string
connect =
"Data Source=(DESCRIPTION ="
+
"(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=xxxx)))"
+
"(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxxxxx)));"
+
"User Id=xxxxx;Password=xxxxxxxx;"
;
string
query =
"SELECT JO_NO,JO_PRD FROM table"
;
using
(OracleConnection conn =
new
OracleConnection(connect))
{
using
(OracleCommand cmd =
new
OracleCommand(query, conn))
{
conn.Open();
Data.DataSource = cmd.ExecuteReader();
Data.DataValueField =
"JO_NO"
;
Data.DataTextField =
"JO_PRD"
;
Data.DataBind();
}
}
}
2) Fetch.aspx Code Behind
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet =
true
)]
public
string
GetData(
string
JO_NO)
{
string
res =
"<p>No customer selected</p>"
;
string
st =
"Data Source=(DESCRIPTION ="
+
"(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=xxxx)))"
+
"(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=xxxxxx)));"
+
"User Id=xxxxx;Password=xxxxxxxx;"
;
Customer com =
new
Customer();
if
(JO_NO !=
null
)
{
StringBuilder sb =
new
StringBuilder();
using
(OracleConnection con =
new
OracleConnection(st))
{
using
(OracleCommand cmd =
new
OracleCommand(
"SELECT JO_QTY,JO_PRD FROM TABLE WHERE JO_NO='"
+ JO_NO +
"'"
, con))
{
con.Open();
OracleDataReader rdr = cmd.ExecuteReader();
if
(rdr.HasRows)
{
while
(rdr.Read())
{
com.CustomerID = rdr[
"JO_PRD"
].ToString();
com.FirstName = rdr[
"JO_QTY"
].ToString();
sb.Append(
"<p>"
);
sb.Append(
"<strong>"
+ rdr[
"JO_QTY"
].ToString() +
"</strong><br />"
);
sb.Append(
"<strong>"
+ rdr[
"JO_PRD"
].ToString() +
"</strong><br />"
);
sb.Append(
"</p>"
);
res = sb.ToString();
}
}
}
}
}
return
res;
}
public
class
Customer
{
public
string
CustomerID {
get
;
set
; }
public
string
FirstName {
get
;
set
; }
}
Reply
Answers (
2
)
No response BIND Data to gridview using jquery
Please help to check when loading, error persists below code