I would like to change the cell color of a specific cell in a specific row defined by two datakey values. For example using the following Grid:
Type ID Adjustments
PG 1 $10.00
V3 1 $10.00
PG 2 $134.35
V3 2 $178.60
I would like to change the background of the cells in the Adjustments column for the cells with values $134.35 and $178.60 based on the Type = PG and ID = 2 and the Type = V3 and the ID = 2. Might even get away with simply the ID = 2.
I attempted:
Protected
Sub
rgd_Paycheck_ItemCreated(sender
As
Object
, e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
rgd_Paycheck.ItemCreated
For
Each
item
As
GridDataItem
In
rgd_Paycheck.MasterTableView.Items
Dim
keyrow_PGPayrollID
As
String
= item.GetDataKeyValue(
"PGPayrollID"
).ToString()
Dim
keyrow_RECTYPE
As
String
= item.GetDataKeyValue(
"RECTYPE"
).ToString()
If
keyrow_PGPayrollID = 2
And
keyrow_RECTYPE
Like
"PG"
Then
Dim
TotalAdjustments_PG
As
String
= item(
"TotalAdjustments"
).Text
Session(
"TotalAdjustments_PG"
) = TotalAdjustments_PG
End
If
If
keyrow_PGPayrollID = 2
And
keyrow_RECTYPE
Like
"V3"
Then
Dim
TotalAdjustments_V3
As
String
= item(
"TotalAdjustments"
).Text
Session(
"TotalAdjustments_V3"
) = TotalAdjustments_V3
End
If
If
Session(
"TotalAdjustments_PG"
) <> Session(
"TotalAdjustments_V3"
)
Then
Label1.Text =
"OOPS"
If
(
TypeOf
(e.Item)
Is
GridDataItem)
Then
'Get the instance of the right type
Dim
dataBoundItem
As
GridDataItem = e.Item
'Check the formatting condition
If
keyrow_RECTYPE =
"PG"
Then
dataBoundItem(
"TotalAdjustments"
).ForeColor = Color.Red
dataBoundItem(
"TotalAdjustments"
).Font.Bold =
True
'Customize more...
End
If
End
If
End
If
Next
End
Sub
And attempted:
Protected
Sub
rgd_Paycheck_ItemDataBound(sender
As
Object
, e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
rgd_Paycheck.ItemDataBound
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
dataBoundItem
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
If
dataBoundItem.GetDataKeyValue(
"PGPayrollID"
).ToString() =
"PG"
And
dataBoundItem.GetDataKeyValue(
"RECTYPE"
).ToString() =
"V3"
Then
dataBoundItem(
"TotalAdjustments"
).ForeColor = Color.Red
dataBoundItem(
"TotalAdjustments"
).Font.Bold =
True
End
If
End
If
End
Sub
As always, any assistance much appreciated.
Allan
Hello everyone,
I have a little problem I have on left hand side of RadGrid textboxes and search button... on the right hand side I have a Rad grid that been loaded with info from DB... my question after filling the text boxes with info to search I want to allow on key press enter instead of the user click to search data in the radgrid how can I do this??
***************************************aspx filter code*****************************************
<telerik:RadPanelBar runat="server" ID="rpbMainMenu" Width="248px" Height="517px" ExpandMode="FullExpandedItem" >
<Items>
<telerik:RadPanelItem Expanded="True" ImageUrl="../Images/Layout/phone_edited.png" Text="Phone Book Search">
<ContentTemplate>
<div style=" border:0px solid red; padding:20px 0px 0px 10px">
<table class="filtersTable">
<tr>
<td>Contact Type:</td>
<td><telerik:RadComboBox runat="server" CheckBoxes="true" ID="rcbFilterPersonType" EmptyMessage="Select Person Type" Enabled="True"></telerik:RadComboBox></td>
</tr>
<tr>
<td>First Name:</td>
<td><asp:TextBox ID="txtFilterFirstName" runat="server" MaxLength="50"></asp:TextBox></td>
</tr>
<tr>
<td>Last Name:</td>
<td><asp:TextBox ID="txtFilterLastName" runat="server" MaxLength="50"></asp:TextBox></td>
</tr>
<tr>
<td>Company:</td>
<td><asp:TextBox ID="txtFilterCompany" runat="server" MaxLength="25"></asp:TextBox></td>
</tr>
<tr>
<td>Email:</td>
<td><asp:TextBox ID="txtFilterEmail" runat="server" MaxLength="50"></asp:TextBox></td>
</tr>
<tr>
<td>Cell Phone:</td>
<td> <asp:TextBox id="txtFilterCellPhone" runat="server" MaxLength="50" ></asp:TextBox></td>
</tr>
<tr>
<td> </td>
<td>
<telerik:RadButton ID="pSearchBtn" runat="server" Text="Search" Style="display: block; width: 80px;" AutoPostBack="true" OnClick="GeneralSearchBtn_Click" Font-Bold="False" ButtonType="SkinnedButton">
<Icon PrimaryIconCssClass="rbSearch" PrimaryIconLeft="4" PrimaryIconTop="4"></Icon>
</telerik:RadButton>
</td>
</tr>
</tr>
</table>
</div>
</ContentTemplate>
</telerik:RadPanelItem>
</Items>
</telerik:RadPanelBar>
*******aspx rad grid*******************
<telerik:RadGrid
ID="rgPhoneBook"
runat="server"
Width="100%"
AutoGenerateColumns="False"
AllowPaging="True"
AllowSorting="True"
PageSize="20"
CellSpacing="0" GridLines="None" Height="100%"
OnItemCommand="rgPhoneBook_ItemCommand"
OnPageIndexChanged="rgPhoneBook_OnPageIndexChanged"
OnSortCommand="rgPhoneBook_OnSortCommand"
EnableHeaderContextFilterMenu="False">
<ClientSettings>
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="2" ScrollHeight="380px"/>
</ClientSettings>
<PagerStyle Mode="NumericPages"></PagerStyle>
<MasterTableView ShowHeadersWhenNoRecords="true" Font-Size="11px" GridLines="None" AllowPaging="True" CommandItemDisplay="Top" AllowAutomaticUpdates="False" TableLayout="Fixed">
<Columns>
<telerik:GridBoundColumn DataField="PersonID" Display="false"/>
<telerik:GridTemplateColumn HeaderText="First Name" HeaderStyle-Width="120px" SortExpression="FirstName">
<ItemTemplate>
<%# RenderActiveUser(DataBinder.Eval(Container.DataItem, "Active"))%> <%# DataBinder.Eval(Container.DataItem, "FirstName")%>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn HeaderText="Last Name" HeaderStyle-Width="120px" ItemStyle-Width="130px" DataField="LastName" ShowFilterIcon="false" SortExpression="LastName" CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true"/>
<telerik:GridBoundColumn HeaderText="Company" HeaderStyle-Width="80px" ItemStyle-Width="130px" DataField="Company" ShowFilterIcon="false" SortExpression="Company" CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true"/>
<telerik:GridBoundColumn HeaderText="Email" HeaderStyle-Width="150px" ItemStyle-Width="70px" DataField="Email" ShowFilterIcon="false" SortExpression="Email" CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true"/>
<telerik:GridBoundColumn HeaderText="Mobile Phone" HeaderStyle-Width="120px" ItemStyle-HorizontalAlign="Left" DataField="CellNum" ShowFilterIcon="false" SortExpression="CellNum" CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true"/>
<telerik:GridBoundColumn HeaderText="Person Type" HeaderStyle-Width="130px" ItemStyle-HorizontalAlign="Left" DataField="PeopleType" ShowFilterIcon="false" SortExpression="PeopleType" CurrentFilterFunction="StartsWith" AutoPostBackOnFilter="true"/>
<telerik:GridTemplateColumn HeaderText="Edit" HeaderStyle-Width="70px">
<ItemTemplate>
<%# GenerateEditLink(DataBinder.Eval(Container.DataItem, "PersonID"))%>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<CommandItemTemplate>
<div style="padding: 5px 5px;">
<table class="rcCommandTable" width="100%">
<td>
<asp:LinkButton ID="lbAddNewPerson" runat="server" CssClass="rgAdd" Width="20" Height="20" OnClientClick="Javascript:return showDialogInitially();" ></asp:LinkButton> Add New Person
</td>
</table>
</div>
</CommandItemTemplate>
</MasterTableView>
</telerik:RadGrid>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Help Me!
- How to Binding data to GridDropDownColumn from DataBase
- How to Insert/Update Value in Editmode for Ragird
Thank !
Help Me!
VS2010, RadControls for ASP.NET AJAX Q3 2010. FrameWork 4.0
- How to Binding data to GridDropDownColumn from DataBase
- How to Insert/Update Value for Ragird1
Thank !
ASPX File
<%@ Page Language="C#" AutoEventWireup="true" validateRequest="false" enableEventValidation="false" CodeFile="HuyenThi_Datao.aspx.cs" Inherits="HuyenThi_Datao" MasterPageFile="~/AdminMasterPage.master" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<asp:Content ID="ContentHuyenThi_Datao" ContentPlaceHolderID="ContentPlaceHolder" runat="server">
<!-- content begin -->
<div class="qsf_content_area_wrapper">
<div class="qsf_content_area">
<table cellspacing="0" cellpadding="0" border="0"
style="width: 95%; height: 18px;">
<tr>
<td style="width: 350px">
</td>
<td >
<asp:CheckBox ID="CheckBox2" Text="Chọn tất cả các trang" runat="server" Height="22px">
</asp:CheckBox>
</td>
<td style="width: 120px">
<asp:Button ID="Button1" CssClass="button" Width="110px" Text="Export to Excel" OnClick="Button1_Click"
runat="server" Height="22px">
</asp:Button>
</td>
<td style="width: 120px">
<asp:Button ID="Button2" CssClass="button" Width="110px" Text="Export to Word" OnClick="Button2_Click"
runat="server" Height="22px">
</asp:Button>
</td>
<td style="width: 120px">
<asp:Button ID="Button3" CssClass="button" Width="110px" Text="Export to CSV" OnClick="Button3_Click"
runat="server" Height="22px">
</asp:Button>
</td>
<td style= "width:120px" >
<telerik:RadButton ID="RadButton3" runat="server" Width="110px" PostBackUrl="~/HuyenThi.aspx"
Text="Tạo Mới" Height="22px">
</telerik:RadButton>
</td>
</tr>
</table>
<br />
<script type="text/javascript">
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
args.get_eventTarget().indexOf("ExportToCsvButton") >= 0) {
args.set_enableAjax(false);
}
}
</script>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr >
<td >
<telerik:RadButton ID="RadButton2" runat="server" Font-Bold="True"
Font-Names="Times New Roman" Font-Size="XX-Large" ForeColor="#0066FF" ReadOnly="True"
Text=" Huyen Thi created" Height="20px" Width="98%"
EnableBrowserButtonStyle="True">
</telerik:RadButton>
</td>
</tr>
</table>
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid2">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid2"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid Width="98%" runat="server" ID="RadGrid1" AllowPaging="True"
AllowSorting="True" OnDeleteCommand = "RadGrid1_DeletedCommand"
OnInsertCommand = "RadGrid1_InsertCommand" OnUpdateCommand= "RadGrid1_UpdateCommand"
MasterTableView-NoMasterRecordsText="No Recorde"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnSortCommand="RadGrid1_SortCommand"
OnPageIndexChanged="RadGrid1_PageIndexChanged"
OnPageSizeChanged="RadGrid1_PageSizeChanged" EnableViewState="False"
GridLines="None" Skin="Web20" AllowFilteringByColumn="True" PageSize="15"
CellSpacing="-1">
<MasterTableView DataKeyNames="HuyenThiId" AutoGenerateColumns="False" EditMode="EditForms"
Width="100%" AdditionalDataFieldNames="HuyenThiId" AllowNaturalSort="False"
EnableViewState="False" Font-Bold="False" Font-Italic="False"
Font-Overline="False" Font-Strikeout="False" Font-Underline="False"
GridLines="None">
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<Columns>
<telerik:GridEditCommandColumn HeaderText="UpDate" EditText="UpDate">
</telerik:GridEditCommandColumn>
<telerik:GridDropDownColumn UniqueName="TinhTen" ListDataMember="TinhTen" SortExpression="TinhTen" ListTextField="TinhTen" EnableEmptyListItem="true"
EmptyListItemText="--Chọn Tỉnh--" EmptyListItemValue="" ListValueField="TinhId" HeaderText="Tên Tỉnh" DataField="TinhId" >
</telerik:GridDropDownColumn>
<telerik:GridBoundColumn DataField="HuyenThiId" HeaderText="ID HuyenThiId" ReadOnly="True" SortExpression="HuyenThiId"
UniqueName="HuyenThiId" Visible="false">
<HeaderStyle Width="20px" ForeColor="Silver" />
<ItemStyle ForeColor="Silver" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="HuyenThiTen" HeaderText="Ten Huyen Thi" SortExpression="HuyenThiTen"
UniqueName="HuyenThiTen" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="HuyenThiMoTa" HeaderText="Mô Tả" SortExpression="HuyenThiMoTa"
UniqueName="HuyenThiMoTa" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false">
</telerik:GridBoundColumn>
<telerik:GridHyperLinkColumn DataNavigateUrlFields="HuyenThiId" HeaderText="EDIT" DataNavigateUrlFormatString="~/HuyenThi.aspx?Id={0}"
Text="<img alt='EDIT' src='images\Edit.gif' border='0' />"
UniqueName= "SuaColumn" AllowFiltering="False">
<HeaderStyle HorizontalAlign="center" />
<ItemStyle HorizontalAlign="Center" />
</telerik:GridHyperLinkColumn>
<telerik:GridButtonColumn CommandName="Delete" HeaderText="Del" ConfirmText=" Del Huyen Thi " Text="<img alt='Del' src='images\Delete.gif' border='0' />" UniqueName= "DeleteColumn" >
<HeaderStyle HorizontalAlign="center" />
<ItemStyle HorizontalAlign="Center" />
</telerik:GridButtonColumn>
</Columns>
<PagerStyle AlwaysVisible="True" />
</MasterTableView>
<FilterMenu>
<CollapseAnimation Type="None" />
</FilterMenu>
<HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Web20"></HeaderContextMenu>
</telerik:RadGrid>
</div>
</div>
</asp:Content>
ASPX.CS File
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Bussiness;
using Model;
using Telerik.Web.UI;
public partial class HuyenThi_Datao : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
RadGrid1.ItemDataBound += new GridItemEventHandler(RadGrid1_ItemDataBound);
}
//Load data
protected void LoadData()
{
RadGrid1.DataSource = ListHuyenThiService.SelectHuyenThiInTinhAll();
RadGrid1.DataBind();
RadGrid1.MasterTableView.GetColumn("HuyenThiTen").Display = true;
RadGrid1.MasterTableView.GetColumn("DeleteColumn").Display = true;
RadGrid1.MasterTableView.GetColumn("SuaColumn").Display = true;
}
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = ListHuyenThiService.SelectHuyenThiInTinhAll();
}
protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
// How to get Value to Update Database
}
protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
// How to get Value to Update Database
}
private void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
GridEditManager editMan = editedItem.EditManager;
GridDropDownListColumnEditor editor = editMan.GetColumnEditor("TinhTen") as GridDropDownListColumnEditor;
editor.DataSource = ListTinhService.SelectTinhAll();
editor.DataBind();
}
}
protected void RadGrid1_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
{
LoadData();
}
protected void RadGrid1_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e)
{
LoadData();
}
protected void RadGrid1_SortCommand(object sender, Telerik.Web.UI.GridSortCommandEventArgs e)
{
LoadData();
}
protected void RadGrid1_DeletedCommand (object source, Telerik.Web.UI.GridCommandEventArgs e)
{
//Get the GridDataItem of the RadGrid
GridDataItem item = (GridDataItem)e.Item;
//Get the primary key value using the DataKeyValue.
int intHuyenThiID = Convert.ToInt32(item.OwnerTableView.DataKeyValues[item.ItemIndex]["HuyenThiId"]);
try
{
HuyenThiService.DeleteHuyenThi(intHuyenThiID);
//Insert Log
string strDes = "Xóa Huyện Thị ID=" + intHuyenThiID;
string strIP = HttpContext.Current.Request.UserHostAddress;
LogService.CreateLog(Page.User.Identity.Name, strDes, DateTime.Now, strIP);
LoadData();
}
catch (Exception ex)
{
RadGrid1.Controls.Add(new LiteralControl("Không xóa được Nhóm này."));
e.Canceled = true;
}
}
protected void Button1_Click(object sender, System.EventArgs e)
{
ConfigureExport();
RadGrid1.MasterTableView.ExportToExcel();
}
protected void Button2_Click(object sender, System.EventArgs e)
{
ConfigureExport();
RadGrid1.MasterTableView.ExportToWord();
}
protected void Button3_Click(object sender, System.EventArgs e)
{
ConfigureExport();
RadGrid1.MasterTableView.ExportToCSV();
}
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToExcelCommandName ||
e.CommandName == Telerik.Web.UI.RadGrid.ExportToWordCommandName ||
e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName)
{
ConfigureExport();
}
}
public void ConfigureExport()
{
RadGrid1.ExportSettings.ExportOnlyData = true;
RadGrid1.ExportSettings.IgnorePaging = CheckBox2.Checked;
RadGrid1.ExportSettings.OpenInNewWindow = true;
RadGrid1.ExportSettings.FileName = "HuyenThi_Export_" + DateTime.Now.ToString("dd.MM.yyyy");
RadGrid1.ExportSettings.HideStructureColumns = true;
}
}
Hello, Everyone.
I am trying to add an image to content in RAD editor. I call the Image Manager window and when I click on the Images folder and Image Manager tries to parse the folder content the progress indicator displays inside the image list pane and never ends. I can access images stored in the root of the image folder location however if I need to navigate to a subfolder under the image folder root I experience the problem with accessing the content - Image Manager can never finish the job of reading the folder content and displaying it in the pane.
Refreshing the folder pane works fine. The same thing happens when I access the Document Manager. I double checked security settings and the AppPool has full access rights to any of these folders.
Any suggestions how to fix this?
Thanks everyone in advance
Hi,
We are using the args parameter for windows a lot throughout our application, and something has changed here since the last version!
For example if setting the OnClientClick="function(sender, args){alert(args.get_argument());}", in the old version (2015 Q2) that return "null" when closing the window, but in the new Q3 release it returns "object" when pressing the close button of the radwindow!
Full example:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="window.aspx.vb" Inherits="TestaTredjepartWeb.window" %>
<!DOCTYPE html>
<
html
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"s"
runat
=
"server"
>
</
asp:ScriptManager
>
<
div
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
>
<
Windows
>
<
telerik:RadWindow
ID
=
"RadWindow1"
runat
=
"server"
VisibleOnPageLoad
=
"true"
RenderMode
=
"Lightweight"
Title
=
"Hello"
OnClientClose
=
"function(sender, args){alert(args.get_argument());}"
>
</
telerik:RadWindow
>
</
Windows
>
</
telerik:RadWindowManager
>
</
div
>
</
form
>
</
body
>
</
html
>
The object returned seems to be a browser event-object... And when examining your source code it tries to detect this and return null, but only if the object is a Sys.UI.DomEvent, which it isn't in the new version!
Regards
Andreas