Advertisement

02.11.2008 at 10:55AM PST, ID: 23153942
[x]
Attachment Details

Best way to use the datagrid delete command

Asked by michael1174 in C# Programming Language, Programming for ASP.NET

Hello,

I am trying to delete a row in a datagrid.  The datagrid's record source is a datatable.  When I click on the delete image button, it triggers this, but when I rebind the grid on another button's event, the row I deleted, re-appears.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
private void dgAttachedWordings_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
			DataTable attachedWordingsTable = this.Session[ATTACHED_WORDINGS_TABLE] as DataTable;
 
			int intWordingCode = GetColNum(dgAttachedWordings.Columns, "Wording Code");
 
			foreach(DataRow row in attachedWordingsTable.Rows)
			{
				if (row[0].ToString() == e.Item.Cells[intWordingCode].Text)
				{
					row.Delete();
 
					attachedWordingsTable.DefaultView.Sort = "SortCode ASC, WordingCode ASC";
					this.Session[ATTACHED_WORDINGS_TABLE] = attachedWordingsTable;
 
					dgAttachedWordings.DataSource = attachedWordingsTable;
					dgAttachedWordings.DataBind();
 
					return;
				}
			}
		}
[+][-]02.11.2008 at 12:08PM PST, ID: 20869730

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.11.2008 at 12:30PM PST, ID: 20869929

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.11.2008 at 10:36PM PST, ID: 20872864

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 03:07AM PST, ID: 20873869

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 03:15AM PST, ID: 20873895

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 03:19AM PST, ID: 20873911

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 03:32AM PST, ID: 20873954

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 04:42AM PST, ID: 20874238

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 05:05AM PST, ID: 20874353

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 08:50PM PST, ID: 20881725

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 05:20AM PST, ID: 20883875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 09:33PM PST, ID: 20891178

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Programming for ASP.NET
Sign Up Now!
Solution Provided By: digitalZo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.14.2008 at 05:37AM PST, ID: 20893054

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628