I have added a new event which is double click, and that event will be fired in a CallBack, everything now works fine, except that, I need to set the Grid in the Edit Mode. The method below is called from the RaiseCallBackEvent method, it is setting the
SelectedIndex right, but the problem is that, the Row is not set in the EditMode.
Am I missing anything?
protected virtual void OnRowDoubleClick(RowDoubleClickEventArgs e)
{
// Set a selection in the Grid
int rowIndex = e.GridViewRow.RowIndex;
// Select the row
this.SelectedIndex = rowIndex;
// Set the edit row
this.EditIndex = rowIndex;
// Change the row state
this.Rows[rowIndex].RowState = DataControlRowState.Edit;
RowDoubleClickEventHandler handler1 = (RowDoubleClickEventHandler)base.Events[xGrid.EventRowDoubleClick];
if (handler1 != null)
{
handler1(this, e);
}
}
Well, I added the Grid.Databind() and now the row is being shown in the Edit Mode. But, when I click Update linkbutton, it just posts back, I have to click it again to update the data. Any ideas?
I was away from my home for one week, now I am back!
I am attaching the code for you, you have mainly two properties till now, one to EnableRowClick and one to EnableEditCallback, the second when you double click, the row is in editable mode, but when I click update nothing happens, no update is done.
Because the code is too big, I will be sending it to you by email!
Yes. I got RowUpdating event working correctly with just one click. But I still need two clicks on Edit button to get the control in edit mode. Dont know why.
haidar_bilal
All-Star
45609 Points
8730 Posts
MVP
Put GridView in Edit Mode Programmatically
Jun 22, 2006 11:20 AM|LINK
Hello:
I am developing an extended GridView.
I have added a new event which is double click, and that event will be fired in a CallBack, everything now works fine, except that, I need to set the Grid in the Edit Mode. The method below is called from the RaiseCallBackEvent method, it is setting the SelectedIndex right, but the problem is that, the Row is not set in the EditMode.
Am I missing anything?
protected virtual void OnRowDoubleClick(RowDoubleClickEventArgs e) { // Set a selection in the Grid int rowIndex = e.GridViewRow.RowIndex; // Select the row this.SelectedIndex = rowIndex; // Set the edit row this.EditIndex = rowIndex; // Change the row state this.Rows[rowIndex].RowState = DataControlRowState.Edit; RowDoubleClickEventHandler handler1 = (RowDoubleClickEventHandler)base.Events[xGrid.EventRowDoubleClick]; if (handler1 != null) { handler1(this, e); } }Thanks a lot.
Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB
ecbruck
All-Star
98783 Points
9691 Posts
Moderator
Re: Put GridView in Edit Mode Programmatically
Jun 22, 2006 11:53 AM|LINK
Once you set the EditIndex, I believe you must rebind your GridView to the DataSource.
Microsoft MVP - ASP.NET
haidar_bilal
All-Star
45609 Points
8730 Posts
MVP
Re: Put GridView in Edit Mode Programmatically
Jun 23, 2006 08:09 AM|LINK
Well, I added the Grid.Databind() and now the row is being shown in the Edit Mode. But, when I click Update linkbutton, it just posts back, I have to click it again to update the data. Any ideas?
Regards
Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB
phuff
Contributor
2700 Points
547 Posts
Microsoft
Re: Put GridView in Edit Mode Programmatically
Jun 28, 2006 05:11 PM|LINK
This posting is provided "AS IS" with no warranties, and confers no rights.
haidar_bilal
All-Star
45609 Points
8730 Posts
MVP
Re: Put GridView in Edit Mode Programmatically
Jul 03, 2006 08:28 PM|LINK
Hello Polita: How are you? Hope all is fine.
I was away from my home for one week, now I am back!
I am attaching the code for you, you have mainly two properties till now, one to EnableRowClick and one to EnableEditCallback, the second when you double click, the row is in editable mode, but when I click update nothing happens, no update is done.
Because the code is too big, I will be sending it to you by email!
Thanks a lot.
Regards
Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB
CJohn
Member
174 Points
68 Posts
Re: Put GridView in Edit Mode Programmatically
Feb 16, 2007 07:52 PM|LINK
luvdairish
Member
146 Points
231 Posts
Re: Put GridView in Edit Mode Programmatically
Feb 22, 2007 04:31 PM|LINK
"Sometimes I spend so much time going the wrong direction on a problem. K.I.S.I.S = Keep It Simple I'm Stupid :)"
Matt
phuff
Contributor
2700 Points
547 Posts
Microsoft
Re: Put GridView in Edit Mode Programmatically
Feb 22, 2007 05:26 PM|LINK
This posting is provided "AS IS" with no warranties, and confers no rights.
CJohn
Member
174 Points
68 Posts
Re: Put GridView in Edit Mode Programmatically
Feb 22, 2007 05:52 PM|LINK
Yes. I got RowUpdating event working correctly with just one click. But I still need two clicks on Edit button to get the control in edit mode. Dont know why.
protected
void gvabc_RowUpdating(object sender, GridViewUpdateEventArgs e){
try{
_a= Convert.ToInt32(((Label)gvabc.Rows[gvabc.EditIndex].Cells[0].Controls[1]).Text.Trim().ToString());_b= ((
TextBox)gvabc.Rows[gvabc.EditIndex].Cells[1].Controls[1]).Text.Trim().ToString();_c= ((
TextBox)gvabc.Rows[gvabc.EditIndex].Cells[2].Controls[1]).Text.Trim().ToString();_d= ((
TextBox)gvabc.Rows[gvabc.EditIndex].Cells[3].Controls[1]).Text.Trim().ToString();_e=
Convert.ToDecimal(((TextBox)gvabc.Rows[gvabc.EditIndex].Cells[4].Controls[1]).Text.Trim().ToString());_f=
Convert.ToDecimal(((TextBox)gvabc.Rows[gvabc.EditIndex].Cells[5].Controls[1]).Text.Trim().ToString());_g=
Convert.ToDecimal(((TextBox)gvabc.Rows[gvabc.EditIndex].Cells[6].Controls[1]).Text.Trim().ToString());_h=
Convert.ToDecimal(((TextBox)gvabc.Rows[gvabc.EditIndex].Cells[7].Controls[1]).Text.Trim().ToString());_abcPresenter.UpdateformDetail();
gvabc.EditIndex = -1;
BindGrid();
catch(Exception ex){
throw new Exception(ex.Message);}
}
Note: I have changed the variable names to protect the identity.
phuff
Contributor
2700 Points
547 Posts
Microsoft
Re: Put GridView in Edit Mode Programmatically
Feb 22, 2007 06:33 PM|LINK
This posting is provided "AS IS" with no warranties, and confers no rights.