Any ideas? I basically want to programatically reproduce the affect of clicking the edit button.
6 Answers, 1 is accepted
Set the EnablePostBackOnRowClick property to True and then try out the following code to set selected rows into EditMode.
This is what I have, but it doesn't do anything except turn the rows yellow (indicating edit mode) but the edit controls (In Place Edit Mode) do not become available:
<asp:CheckBox ID="cbEditAll" runat="server" Text="Edit All" CssClass="Normal"
OnCheckedChanged="editAll" AutoPostBack="True" />
Public Sub editAll(ByVal sender As Object, ByVal e As System.EventArgs)
For Each gridItem As GridItem In rgT.MasterTableView.Items
Is it possible to do this? It seems like a simple thing to do but it doesn't seem to register that the rows are actually in open edit mode.
Thanks for the help!
You can try out the following code which allows you to set the entire grid into EditMode if the checkbox is checked and sets it to NormalMode if the checkbox is unchecked.
For Each data As GridDataItem In rgT.MasterTableView.Items
The problem is it still only sets the rows to be yellow as though they were in edit mode but they are still not editable. I don't see the editable controls still. There must be command that tells it to open up the editable controls in my templated columns.
If (e.CommandName = "EditAll") Then
For Each item As GridItem In rgT.MasterTableView.Items
Dim cbAppCntrl As CheckBox = CType(item.FindControl("chkApproved"), CheckBox)
If (TypeOf item Is GridDataItem) Then
If (Not cbAppCntrl.Checked) Then
ElseIf (cbAppCntrl.Checked) Then
The problem is that as you can see I am trying to NOT put the rows that are checked as approved (cbAppCntrl.Checked) into edit mode, yet it seems to ignore this. It hits the code and sets the edit property to false as it should, yet after I requery and refill the grid those approved rows are still in edit mode.
Thanks for the help Princy you led me in the right direction I just wasn't able to get it to work with a checkbox (which is fine) and I can't seem to skip the approved rows being set to edit mode.
protected void m_rgPolicyModules_ItemDataBound(object sender, GridItemEventArgs e)
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
DataRowView drv = e.Item.DataItem as DataRowView;
GridEditableItem item = e.Item as GridEditableItem;
if (drv["ModuleType"].ToString() != "Optional Module")
"Selected"].Enabled = false;
Hope this helps someone :)