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
abas shahen
NA
66
0
The Rows Deleted From DataBase but the Rows in The DataTable remain unchanged :(
Dec 15 2009 5:10 AM
this is my code note : the code work without any error , and the required change to database is done successfuly , but the rows in DATATABLE remain unchanged after delete them by datatable.removeat() method: protected void btnBlock_Click(object sender, EventArgs e) { Guid UserId = (Guid)Session["UserId"]; if (UserId != null) { Contact contact1 = new Contact(); DataTable dt = new DataTable(); DataTable dt2 = new DataTable(); dt2 = (DataTable)ViewState["BlockedContact"]; dt = (DataTable)ViewState["contactlist"]; if (dt != null) { int count = 0; int count2 = 0; DataRow row = null; SetData(); gvContacts.AllowPaging = false; gvContacts.DataBind(); ArrayList arr = (ArrayList)ViewState["SelectedRecords"]; count = arr.Count; for (int i = 0; i < gvContacts.Rows.Count; i++) { for (int x = 0; x < dt.Rows.Count-1 ; x++) { if (arr.Contains(gvContacts.DataKeys[i].Value)) { /// this code block user successfuly from database contact1.BlockUser(gvContacts.DataKeys[i].Value.ToString(), UserId); if (dt.Rows[x][0].ToString() == gvContacts.DataKeys[i].Value.ToString()) { dt.Rows.RemoveAt(count2); row = dt.NewRow(); dt2.Rows.Add(); dt2.Rows[dt2.Rows.Count - 1]["ImageID"] = row["ImageID"]; dt2.Rows[dt2.Rows.Count - 1]["UserName"] = row["UserName"]; dt.Rows[dt2.Rows.Count - 1]["FirstName"] = row["FirstName"]; dt2.Rows[dt2.Rows.Count - 1]["LastName"] = row["LastName"]; dt2.Rows[dt2.Rows.Count - 1]["LastActivityDate"] = row["LastActivityDate"]; dt.Rows.RemoveAt(count2); arr.Remove(gvContacts.DataKeys[i].Value); } } } } ViewState["BlockedContact"] = dt2; ViewState["contactlist"] = dt; ViewState["SelectedRecords"] = arr; hfCount.Value = "0"; gvContacts.AllowPaging = true; gvContacts.DataSource = dt2; gvContacts.DataBind(); ShowMessage(count); } } }
Reply
Answers (
6
)
Add Columns with ADO.Net parameters
createuserwizard email verification.