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
Itsme
NA
107
5.4k
while deleting throwing error.
Oct 1 2019 4:40 AM
I want to delete selected record but it is giving me error--System.Web.HttpException: 'DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Id'.'
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" Text="Delete"
ImageUrl="~/Images/delete.png" Width="50px" Height="50px" CommandArgument='<%# Eval("Id") %>'
CommandName="Deleterow" />
</ItemTemplate>
</asp:TemplateField>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Deleterow")
{
string id = e.CommandArgument.ToString();
string constr = ConfigurationManager.ConnectionStrings["Q_SS_regnConnectionString1"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand sq = new SqlCommand("DELETE FROM Booking where Id='" + id + "'", con);
sq.ExecuteNonQuery();
con.Close();
}
}
Reply
Answers (
3
)
On Click of Button downld zip and Count no of times clicked
Pop up Window with a search box