Click here to Skip to main content
15,847,750 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Here i am returning table one row data

[WebMethod]
public static GalleryDetailsInPopup[] BindDatatable(int imageId)
{
DataTable dt = new DataTable();
List<GalleryDetailsInPopup> details = new List<GalleryDetailsInPopup>();
using (SqlConnection con = new SqlConnection("Server=SERVER1; Database=WomensClothing; uid=sa; pwd=elife@123"))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "Get_galleryImages";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@imageId", imageId);
cmd.Connection = con;
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
foreach (DataRow dtrow in dt.Rows)
{
GalleryDetailsInPopup popupDetails = new GalleryDetailsInPopup();
popupDetails.ImageId = Convert.ToInt32(dtrow["ImageId"].ToString());
popupDetails.OwnerName = dtrow["OwnerName"].ToString();
popupDetails.FrontImage = dtrow["FrontImage"].ToString();
popupDetails.BackImage = dtrow["BackImage"].ToString();
popupDetails.DesignedBy = dtrow["DesignedBy"].ToString();
popupDetails.FrontStyle = dtrow["FrontStyle"].ToString();
popupDetails.BackStyle = dtrow["BackStyle"].ToString();
popupDetails.BodyFabric = dtrow["BodyFabric"].ToString();
popupDetails.SleeveFabric = dtrow["SleeveFabric"].ToString();
popupDetails.YokeFabric = dtrow["YokeFabric"].ToString();
popupDetails.CollerFabric = dtrow["CollerFabric"].ToString();
popupDetails.Price = Convert.ToDouble(dtrow["Price"].ToString());
details.Add(popupDetails);
}
}
}
return details.ToArray();
}



here i can go in success but cant get data by 'popup.d.ImageId'?

$(document).on("click", "[id*=link" + data.d[i].ImageId + "]", function () {
                        var imageId = $(this).closest("td").find('span').html();
                        alert(imageId);
                        $.ajax({
                            type: "POST",
                            contentType: "application/json; charset=utf-8",
                            url: "gallries.aspx/BindDatatable",
                            data: "{'imageId':'" + imageId + "'}",
                            dataType: "json",
                            success: function (popup) {
                                var frontstyles = popup.ImageId;
                                alert(frontstyles);

                            },
                            error: function (result) {
                                alert("Error");
                            }
                        });

                    });
Posted

I got it by 'popup.d[0].ImageId'
 
Share this answer
 
JavaScript
success: function (popup) { 
       $.each(popup, function(index) {
            alert(popup[index].ImageId);
        });
}
 
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