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
Sandhya Bhosale
NA
18
0
SQL, Visual Studio 2005, C #
Oct 20 2006 2:19 AM
I am facing problem with the code to delete single/multiple row(s) on button click from a datagrid.
The datagrid consists of selectall checkbox. Once a user clicks on this checkbox, all the checkboxes besides each row on that page are checked. Else he can check any one or two rows in the grid to delete just a particular row.
Also, topic id is primary key whose datatype is int.
The code is as follows:
protected
void
btndelete_Click(
object
sender,
EventArgs
e)
{
foreach
(
DataGridItem
dgi
in
MyDataGrid.Items)
{
CheckBox
checkall;
checkall = (
CheckBox
)dgi.FindControl(
"chkselect"
);
string topicid = MyDataGrid.DataKeys[dgi.ItemIndex].ToString();
if
(checkall.Checked==
true
)
{
string
delrecord=
"delete from Admin_Add_Newsletter_Topic where Topic_Id= topicid"
;
SqlConnection
con=
new
SqlConnection
(ConnectionString);
SqlCommand
cmd=
new
SqlCommand
(delrecord, con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
But I receive this error:
Invalid column name 'topicid'.
Please help me
Reply
Answers (
1
)
Error Upon Restoring Transaction Log
BLBO