if (errorCount > 0) { TableCell statusCell = item["STATUS"]; (statusCell.Controls[0] as TextBox).Text = "Error"; (statusCell.Controls[0] as TextBox).BackColor = System.Drawing.Color.Red; } <telerik:RadGrid ID="rdDeposits" AllowSorting="False" AllowPaging="False" runat="server" AutoGenerateColumns="False" AllowAutomaticInserts="False" OnPreRender="rdDeposits_PreRender" AllowAutomaticDeletes="False" Skin="Web20" OnNeedDataSource="rdDeposits_NeedDataSource" OnItemDataBound="rdDeposits_ItemDataBound" GridLines="Horizontal" OnItemCommand="rdDeposits_ItemCommand" OnItemCreated="rdDeposits_ItemCreated" OnDeleteCommand="rdDeposits_ItemDeleted" AllowMultiRowEdit="False" Width="738px" Height="360px"> <MasterTableView ShowFooter="true" DataKeyNames="ESCROW_ACCOUNT_DEPOSIT_ID" CommandItemDisplay="Top" EditMode="InPlace" TableLayout="Fixed"> <CommandItemTemplate> <div style="padding: 5px 5px;"> <asp:Button ID="btnAdd" CommandName="InitInsert" Text="Add Transaction" runat="server" /> </div> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn DataField="ESCROW_ACCOUNT_DEPOSIT_ID" UniqueName="ESCROW_ACCOUNT_DEPOSIT_ID" ReadOnly="true" Visible="false"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn DataField="DEPOSIT_TRANS_TYPE_ID" HeaderText="Type" UniqueName="DEPOSIT_TRANS_TYPE_SDESC" ListTextField="DEPOSIT_TRANS_TYPE_SDESC" ListValueField ="DEPOSIT_TRANS_TYPE_ID" DropDownControlType="DropDownList" ColumnEditorID="GridDropDownColumnEditor1"> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="110px" /> <FooterStyle HorizontalAlign="Right" Font-Bold="true" /> </telerik:GridDropDownColumn> <telerik:GridBoundColumn DataField="EXPECTED_DATE" HeaderText="Expected Date" UniqueName="EXPECTED_DATE" ReadOnly="true"> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="90px" /> <ItemStyle HorizontalAlign="Center" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="EXPECTED_AMOUNT" HeaderText="Expected Amount" UniqueName="EXPECTED_AMOUNT" ReadOnly="true"> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="100px" /> <ItemStyle HorizontalAlign="Right"/> <FooterStyle HorizontalAlign="Right" Font-Bold="true" /> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn DataField="ACTUAL_DATE" HeaderText="Actual Date" UniqueName="ACTUAL_DATE" DataType="System.DateTime" ColumnEditorID="GridDateTimeColumnEditor"> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="100px" /> </telerik:GridDateTimeColumn> <telerik:GridNumericColumn DataField="ACTUAL_AMOUNT" HeaderText="Actual Amount" UniqueName="ACTUAL_AMOUNT" NumericType="Currency" Resizable="False" MaxLength="8" DataType="System.Decimal" > <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="100px" /> <ItemStyle HorizontalAlign="Center" /> <FooterStyle HorizontalAlign="Right" Font-Bold="true" /> </telerik:GridNumericColumn> <telerik:GridBoundColumn DataField="STATUS" HeaderText="Status" UniqueName="STATUS" ReadOnly="true"> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="90px" /> <ItemStyle HorizontalAlign="Center" /> </telerik:GridBoundColumn> <telerik:GridButtonColumn ButtonType="ImageButton" Text="Delete" ImageUrl='../Images/deleteX.GIF' CommandName="Delete" UniqueName="Delete"> <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Width="15px" /> </telerik:GridButtonColumn> <telerik:GridBoundColumn DataField="EXPECTED_TRANSACTION_IND" UniqueName="EXPECTED_TRANSACTION_IND" ReadOnly="true" Visible="false" ForceExtractValue="Always" > </telerik:GridBoundColumn> </Columns> </MasterTableView> <SelectedItemStyle BackColor="#F8C320" /> <ClientSettings EnableRowHoverStyle="true"> <Selecting AllowRowSelect="true" /> <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" /> </ClientSettings> </telerik:RadGrid>Hi, I have a question in regards to selective delete. I have a grid with delete option defined as below
<telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="DeleteAlignment">
Now, I want to selectivele remove the delete option on some of the rows. Is there a way to do that? So I wan say delete option on the first 5 rows only... or something like that
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
var ds = new List<object>();
for (int i = 0; i < 100; i++)
{
ds.Add(new { A = "AA" });
}
this.rgFr.DataSource = ds;
this.rgFr.DataBind();
}
}
Hi,
I'm relatively new to the Radgrid and EntitySpaces. I know that they work extremely well together but I've been stumped for a few hours today with a problem. I've got a rad grid that is bound to an esDataSource, the datasource has a field that is a lookup value. I can bind the grid to the initial datasource and at this stage insertion and editing works fine. However, when I use a template column to add an dropdown control for the look up field (binding it in the ItemDataBound event handler), I can edit values well but when I insert new values though the lookup values are saved as empty values. I cant seem to grab the lookup dropdown value during the insert event.
Any suggestions would be helpful. Sample code or examples would be appriciated.
Here's my code:
<asp:Panel ID="pnlBreadcrumb" runat="server"> </asp:Panel> <asp:Label ID="lblMessage" runat="server" Visible="false" Text="No list configuration found" /> <telerik:RadGrid ID="grdLevelValues" runat="server" GridLines="None" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" DataSourceID="datListValues" AutoGenerateColumns="False" onitemcommand="grdLevelValues_ItemCommand" onitemdatabound="grdLevelValues_ItemDataBound" onitemcreated="grdLevelValues_ItemCreated" AllowSorting="True" AllowPaging="True" PageSize="25" > <HeaderContextMenu EnableAutoScroll="True"></HeaderContextMenu> <MasterTableView datakeynames="IdBusinessUnit" datasourceid="datListValues" CommandItemDisplay="Top" EditMode="InPlace"> <Columns> <telerik:GridBoundColumn DataField="BusinessUnitName" HeaderText="Business Unit" UniqueName="column1"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn UniqueName="State"> <HeaderTemplate> <asp:Label ID="lblStateNameHeader" Text="State Name" runat="server"></asp:Label> </HeaderTemplate> <ItemTemplate> <asp:Label ID="lblStateName" runat="server" Text='<%# Eval("UpToAddressStateItemByIdState.State") %>' /> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlStateName" runat="server"></asp:DropDownList> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn> </Columns> <EditFormSettings> <EditColumn UniqueName="EditCommandColumn1"></EditColumn> </EditFormSettings> </MasterTableView> </telerik:RadGrid> <cc1:esDataSource ID="datListValues" runat="server" onescreateentity="datListValues_esCreateEntity" onesselect="datListValues_esSelect" AutoPaging="true" AutoSorting="true"/> protected void Page_Load(object sender, EventArgs e) { } protected void grdLevelValues_ItemCommand(object source, GridCommandEventArgs e) { } protected void grdLevelValues_ItemDataBound(object sender, GridItemEventArgs e) { if ((e.Item is GridEditableItem) && e.Item.IsInEditMode) { AddressStateCollection states = new AddressStateCollection(); states.Query.SelectAll(); states.Query.Load(); GridEditableItem gridEditableItem = (GridEditableItem)e.Item; DropDownList dropDownList = (DropDownList)gridEditableItem["State"].FindControl("ddlStateName"); dropDownList.DataSource = states; dropDownList.DataTextField = "State"; dropDownList.DataValueField = "IdState"; //Find the selected index by assuming that the ddl datasource will maintain the order inwhich its items were added. int ddlSelectedIndex =0; foreach(AddressStateItem state in states) { if ((gridEditableItem.DataItem is GridInsertionObject) == false) { if (state.IdState == System.Convert.ToInt32(((Westpac.VOS.Data.BusinessUnitItem)gridEditableItem.DataItem).IdState)) { break; } ddlSelectedIndex ++; } else break; } dropDownList.SelectedIndex = ddlSelectedIndex; dropDownList.DataBind(); } } protected void grdLevelValues_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem item = e.Item as GridEditableItem; //validation code goes here... } } protected void datListValues_esSelect(object sender, EntitySpaces.Web.esDataSourceSelectEventArgs e) { BusinessUnitCollection values = new BusinessUnitCollection(); values.Query.SelectAll(); values.Query.Load(); e.Collection = values; } protected void datListValues_esCreateEntity(object sender, EntitySpaces.Web.esDataSourceCreateEntityEventArgs e) { BusinessUnitItem entity = new BusinessUnitItem(); // Insert if (e.PrimaryKeys == null) // A new record to be created { entity.AddNew(); entity.IdBrand = VosContext.Current.Brand.Id; foreach (GridDataItem item in this.grdLevelValues.Items) { DropDownList dropDownList = (DropDownList)item["State"].FindControl("ddlStateName"); if (dropDownList != null) { entity.IdState = System.Convert.ToInt32(dropDownList.SelectedValue); } } } else // Update { entity.LoadByPrimaryKey((int)e.PrimaryKeys[0]); foreach (GridDataItem item in this.grdLevelValues.Items) { DropDownList dropDownList = (DropDownList)item["State"].FindControl("ddlStateName"); if (dropDownList != null) { entity.IdState = System.Convert.ToInt32(dropDownList.SelectedValue); } } } e.Entity = entity; } Hi guys,
I have a following code in my aspx page:
<
telerik:GridTemplateColumn HeaderText ="Eis-Id" UniqueName ="PRICol" Groupable="true" DataField="FILENO" SortExpression="FILENO" ReadOnly="true" HeaderButtonType="TextButton">
<ItemTemplate>
<asp:Label ID="PRI" runat="server" ></asp:Label>
<asp:Image ID="Image1" runat="server" AlternateText="EIS CHARGES"/>
</ItemTemplate>
</telerik:GridTemplateColumn>
DetailGrid.MasterTableView.GetColumn(
"PRICol").Visible = false;
gvwMaterial.ExportSettings.ExportOnlyData = true; gvwMaterial.ExportSettings.IgnorePaging = true; gvwMaterial.ExportSettings.OpenInNewWindow = true; gvwMaterial.ExportSettings.Excel.Format = GridExcelExportFormat.Html; gvwMaterial.ExportSettings.FileName = String.Format("File_{0}_{1}_in_{2}.xls", aaa, bbb.ToString(), ccc.ToString()); gvwMaterial.MasterTableView.ExportToExcel();