This is the code from the ItemTemplate
of the ListView
.Here i am usisg labels to display the Item Name,Description etc etc from the database.
I want to use this http://valums.com/edit-in-place/ jQuery plugin to edit the columns.Can anyone please help me out with this??I mean how do i use this plugin to edit the fields and save them after editing to the database.
<ItemTemplate>
<td id="Td2" runat="server" style="background-color:#ffffff; color: #000000;">
<div id="DFIP-Desc">
<table cellpadding="0" cellspacing="0" class="style2" >
<tr style="border:solid 1px #666666;">
<td style="border:solid 1px #666666; width:100px;"> User</td>
<td> <asp:Label ID="userIDLabel" runat="server" Text='<%# Eval("userID") %>' /></td>
</tr>
<tr style="border:solid 1px #666666;">
<td style="border:solid 1px #666666;"> Item Name</td>
<td> <asp:Label ID="itemNameLabel" runat="server" Text='<%# Eval("itemName") %>' /></td>
</tr>
<tr style="border:solid 1px #666666;">
<td style="border:solid 1px #666666; width:100px;"> Offered Price</td>
<td> <asp:Label ID="offeredPriceLabel" runat="server" Text='<%# Eval("offeredPrice") %>' /></td>
</tr>
开发者_高级运维 <tr style="border:solid 1px #666666;">
<td style="border:solid 1px #666666; width:150px;"> Long Description</td>
<td> <asp:Label ID="longDescriptionLabel" runat="server" Text='<%# Eval("longDescription") %>' Font-Size="14px" CssClass="align" /></td>
</tr>
<tr style="border:solid 1px #666666;">
<td style="border:solid 1px #666666; width:100px;"> Bargainable</td>
<td> <asp:Label ID="bargainableLabel" runat="server" Text='<%# Eval("bargainable") %>' /></td>
</tr>
<tr style="border:solid 1px #666666;">
<td style="border:solid 1px #666666; width:100px;"> Condition</td>
<td> <asp:Label ID="conditionLabel" runat="server" Text='<%# Eval("condition") %>' />,(<asp:Label ID="ageYearsLabel" runat="server" Text='<%# Eval("ageYears") %>' /> Years,<asp:Label ID="ageMonthsLabel" runat="server" Text='<%# Eval("ageMonths") %>' /> Months)</td>
</tr>
<tr style="border:solid 1px #666666;">
<td style="border:solid 1px #666666; width:100px;"> Warranty</td>
<td> <asp:Label ID="warrantyLabel" runat="server" Text='<%# Eval("warranty") %>' />,(<asp:Label ID="warrantyYearsLabel" runat="server" Text='<%# Eval("warrantyYears") %>' /> Years,<asp:Label ID="warrantyMonthsLabel" runat="server" Text='<%# Eval("warrantyMonths") %>' /> Months)</td>
<td><asp:Label ID="itemIDLabel" runat="server" Text='<%# Eval("itemID") %>' Visible="True" /></td>
</tr>
</table>
</div>
</td>
</ItemTemplate>
The answer to your question is under the "usage" heading on the link you provided.
You mark a field as editable by finding it with jquery and running editableText(). Ex. put this in a script tag:
$(document).ready(function () {
$('#longDescriptionLabel').editableText();
});
You then have to have a jquery function that catches the change and posts it back to your aspx page:
$(document).ready(function () {
// bind an event listener that will be called when
// user saves changed content
$('#longDescriptionLabel').change(function(){
var newValue = $(this).html();
// do something
// For example, you could place an AJAX call here:
$.ajax({
type: "POST",
url: "savelongDescriptionLabel.aspx",
data: "longDescriptionLabel=" + newValue,
success: function(msg){
alert( "Data Saved: " + msg );
}
});
});
Then in your savelongDescriptionLabel.aspx's page load you request["longDescriptionLabel"] and save it.
You will probably need to get the ID of the item you want to save though, and this you can do by using jquery: $(this).parent.find("#itemIDLabel").val(), then pas that value inside the data bit of the ajax call. });
edit: used . for cssclass instead of # for ID in my jquery selector. edit2: Here is the reference for using ID selectors: http://api.jquery.com/id-selector/
My suggestion would be to hit the books. You admit you really don't understand AJAX or JQuery. You're in no position to ask users here to get your code working. SO users expect posters to put in a minimum of effort before they help. They get annoyed and downvote questions that expect them to do all the work.
Check out general articles for ASP.Net developers such as the following:
http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx
When you have done the research you will be in a position to ask tightly scoped questions that someone will be willing to answer. And more importantly, you will be in a position to actually evaluate what they are telling you.
精彩评论