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
Nitol Biswas
NA
37
1.5k
Input string was not in a correct format
Nov 29 2016 7:00 AM
I use this below code in .aspx file for delete Girdview row.
Asp Code:
<asp:TemplateField HeaderText="mus_id">
<ItemTemplate>
<asp:LinkButton ID="lblDelete" CommandArgument='<%# Eval("mus_id") %>' CommandName="DeleteRow" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
C# Code
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName == "DeleteRow")
{
SqlConnection cs = new SqlConnection("Data Source=DESKTOP-3T94FQ0;Initial Catalog=RAMS;Integrated Security=False;UID=sa;Password=sa123;");
SqlCommand deleteCommand = new SqlCommand("DELETE FROM [tbl_musannet] WHERE [mus_id]= @mus_id",cs);
deleteCommand.Parameters.Add("@mus_id", SqlDbType.BigInt).Value = Convert.ToInt64(e.CommandName);
cs.Open();
deleteCommand.ExecuteNonQuery();
cs.Close();
}
}
But when I going to delete rows "
Input string was not in a correct format
" error is showing.
Please help.
Thanks
Reply
Answers (
1
)
Inject dependency into Controller.
multiple search functionality in asp.net mvc