Problem with editing DataGrid

G

geek

Hi all,

I have a datagrid and I want to be able to edit a particular cell in
datagrid row.
I am using the EditCommandColumn control.My problem is when I hit
update the current row doesn't go in the edit mode.

Here is the snippet for asp:

<asp:EditCommandColumn EditText="Edit" CancelText="Cancel"
UpdateText="Update" HeaderText="Edit Column" ButtonType="LinkButton"
HeaderStyle-Wrap="False"
ItemStyle-Wrap="False"></asp:EditCommandColumn>

Here are my edit,update and cancel methods:
public void EditGrid(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
ReportDataGrid.EditItemIndex = (int)e.Item.ItemIndex;
//ReportDataGrid.
int foo = (int)e.Item.ItemIndex;
daList.Fill(DS,"Recognition");
daRecipient.Fill(DS,"Recipients");
ReportDataGrid.DataSource = DS;
ReportDataGrid.DataBind();

}
public void Update(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string NewData;
TableCell NotesCell = e.Item.Cells[6];
TextBox EditBox;
EditBox = (TextBox)NotesCell.Controls[0];
NewData = EditBox.Text;
//TODO: modify the data in DB acc to the entry
ReportDataGrid.EditItemIndex = -1;
daList.Fill(DS,"Recognition");
daRecipient.Fill(DS,"Recipients");
ReportDataGrid.DataSource = DS;
ReportDataGrid.DataBind();
}
public void Cancel(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
ReportDataGrid.EditItemIndex = -1;
daList.Fill(DS,"Recognition");
daRecipient.Fill(DS,"Recipients");
ReportDataGrid.DataSource = DS;
ReportDataGrid.DataBind();

}

Any help will be appreciated.
Thanks!

MJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top