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
MsDotNet raja
NA
10
2.6k
button click in repeater increments the value in database
Jan 2 2016 12:26 AM
Hi, I have a column called Likes in my db, and in repeater i have a button, if a user clicks on the button the value in db should increase by +1 on every click and the button should display the number of likes in count(as 32 likes).
asp code:
<asp:Button ID="btnlike" CommandName="like" style="height:40px;width:70px" runat="server" Font-Bold="true" BorderColor="Blue" Text="Like" />
C# code:
protected void rptCustomers_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
using (MySqlConnection con = new MySqlConnection(connString))
{
using (MySqlCommand cmd = new MySqlCommand("UPDATE articles SET Likes = Likes+1 WHERE Pid=" + Pid, con))
{
using (con)
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}
Please correct my code, thanx in advance.
Reply
Answers (
4
)
ASP.net Application Deployment On IIS
how to rows of values in asp.net