i am using datalist to display my data , and webservice to acess that data .. but not able to find control of datalist in javascript code , how can i do it ?? help
actually on button click inside datalist i want to store the data of corresponding in another table of database ,, i want to avoid reload of page on button click so i am using jquery ajax for it
this is my javascript :
<script type="text/javascript">
$(documnet).ready(function(){
$('#<%=/button1.ClientID %>').click(function(){
var productid=$('<%=l3.ClientID %>').val();
var prodprice=$('<%=l2.ClientID %>').val();
var prodname=$('<%=l1.ClientID %>').val();
var produrl=$('<%=sh1.ClientID %>').val();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Default.aspx/SaveToDB",
data: '{"productidid":"' + productid + '"prodprice":"' + prodprice + '"produrl":"'+produrl+'"prodname":"' + prodname + '"}',
dataType: "json",
success: function(msg) {
$('.item_wrap').after('<div>' + msg.d + '</div>');
},
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
});
});
});
here is my datalist :
<asp:DataList ID="DataList1" RepeatColumns="4" RepeatLayout="table"
RepeatDirection="horizontal" runat="server" OnItemCommand="DataList1_ItemCommand"
onitemdatabound="DataList1_ItemDataBound" >
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<table class="item_wrap">
<tr >
<td align="center">
<asp:Image ID="sh1" Height="120px" Width="120px" runat ="server"
ImageUrl='<%#Eval("produrl")%>' CssClass="item_pic" />
</td>
</tr>
<tr >
<td class="item_title"><asp:Label ID="l1" runat="server" Text='<%#Eval("prodname")%>' ></asp:Label></td>
</tr>
<tr>
<td class="item_price">Rs.<asp:Label ID="l2" runat="server" Text='<%#Eval("prodprice")%>' >
</asp:Label></td>
<td class="item_price"><asp:Label ID="l3" runat="server"
Text='<%#Eval("productid")%>' Visible="False"></asp:Label></td>
</tr>
<tr>
<td>
<asp:LinkButton ID="/button1" runat="server" Text=" "
CssClass="ImageButton" Height="20px" Width="90px" EnableViewState="True" CommandName=""
/>
</td>
</tr>
</table>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:DataList>
</script>