I am struggling to understand why the following code is putting all rows into edit mode when I click my "Edit All" button, when it should be putting all rows except those which have their checkbox checked. When the code hits the if statement for the checked rows it recognizes that the checkbox is checked and falls into the else part to set item.Edit = False, but after retrieving the transactions in the GetTransactions() method the rows are ALL in edit mode.
I just don't understand how that is happening. Dooes anyone have any ideas?
Here is the code:
If (e.CommandName = "EditAll") Then
For Each item As GridItem In rgT.MasterTableView.Items
Dim cbAppCntrl As CheckBox = CType(item.FindControl("chkApproved"), CheckBox)
If (Not cbAppCntrl.Checked) Then
item.Edit = True
ElseIf (cbAppCntrl.Checked = True) Then
item.Edit = False
End If
Next
GetTransactions()
End If
Thanks!!!
5 Answers, 1 is accepted
I can't tell you why do you get that behavior because I'm new to ASP.NET and Telerik Rad AJAX constrols.
Instead I need a grid that puts all rows in edit mode.
I've tried your code but I recieved some unexpected behavior so can you give me some more details where did you insert that code and what was the trigger for that behavior?
Thanx a lot,
Andrei
You can try out the following code to put the entire grid in EditMode.
cs:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
foreach (GridDataItem item in RadGrid1.Items) |
{ |
item.Edit = true; |
} |
RadGrid1.Rebind(); |
} |
Thanks
Princy.
Is the Items collection of RadGrid refers only to the items within current row?
Here is the code:
ASPX File:
<telerik:RadGrid
ID="ProductsDataSheet"
runat="server"
AutoGenerateColumns="false"
DataSourceID="ProductsDS"
AllowPaging="true"
PageSize="15"
AllowFilteringByColumn="true"
ShowStatusBar="true"
Skin="Office2007"
OnPreRender="ProductsDataSheet_PreRender">
<MasterTableView DataSourceID="ProductsDS">
<Columns>
<telerik:GridBoundColumn
HeaderText="Product"
DataField="ProductName"
UniqueName="ProductName"
DataType="System.String" />
<telerik:GridDropDownColumn
HeaderText="Category"
DataSourceID="ProductsDS"
DataField="CategoryID"
ListTextField="CategoryName"
ListValueField="CategoryID" />
<telerik:GridDropDownColumn
HeaderText="Supplier"
DataSourceID="ProductsDS"
DataField="SupplierID"
ListTextField="SupplierName"
ListValueField="SupplierID" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
Code Behind File:
protected void ProductsDataSheet_PreRender(object sender, EventArgs eventArgs) {
foreach (GridDataItem item in this.ProductsDataSheet.Items) {
item.Edit = true;
}
this.ProductsDataSheet.Rebind();
}
Try setting the AllowMultiRowEdit property for the grid to True as shown below.
Aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource2" AllowMultiRowEdit="True" runat="server" OnPreRender="RadGrid1_PreRender"> |
<MasterTableView DataSourceID="SqlDataSource2" > |
Thanks
Shinu.
Thank you