Hi All
Have a grid with records which works fine.
Have given PageSize="5" Mode="Slider".
Have used custom Skin.
While i click next page in the slider bar only an empty box appears. which is the outline of the grid.
I checked with keeping Debug.
The issue I found is which next page is clicked. The pointer doesn't go into the page load event.
It directly goes into NeedDataSource. so the argument which is passed goes as NULL.
This is dll 2008.3.1314.35.
Here is the .cs page too.
Is there any option to rectify this.
-Anto
Have a grid with records which works fine.
Have given PageSize="5" Mode="Slider".
Have used custom Skin.
While i click next page in the slider bar only an empty box appears. which is the outline of the grid.
I checked with keeping Debug.
The issue I found is which next page is clicked. The pointer doesn't go into the page load event.
It directly goes into NeedDataSource. so the argument which is passed goes as NULL.
This is dll 2008.3.1314.35.
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="Department.aspx.cs" Inherits="iSmart.Department" %> |
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<%@ Register TagPrefix="Ctrl" TagName="HeaderV2" Src="~/Common/HeaderV2.ascx" %> |
<%@ Register TagPrefix="Ctrl" TagName="Left" Src="~/Common/Left.ascx" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title>Department</title> |
<style type="text/css"> |
.GridPager_ImpetusBlue .radslider |
{ |
float: left; |
margin:7px 10px 0 5px; |
padding-bottom:5px; |
} |
tr.SelectedRow_ImpetusBlue td |
{ |
background-color: #FF99FF; |
} |
</style> |
<%--<link rel="stylesheet" type="text/css" href="../Common/includes/style.css"></link>--%> |
<link href="../ImpetusBlue/Grid.ImpetusBlue.css" rel="stylesheet" type="text/css"></link> |
<link href="../ImpetusBlue/Menu.ImpetusBlue.css" rel="stylesheet" type="text/css"></link> |
<link href="../ImpetusBlue/Slider.ImpetusBlue.css" rel="stylesheet" type="text/css"></link> |
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1"> |
<script type="text/javascript"> |
function RTBDivclientButtonClicked(sender, args) { |
if (args.get_item().get_text() == "Delete") { |
//args.set_cancel(true); |
//radalert('Error: Enter Reason', null, 100, "Error"); |
//lastClickedItem = args.get_item(); |
//radalert('Error: Enter Reason', null, 100, "Error"); |
radalert('', null, 100, "Error"); |
radconfirm("Are You Sure, You Want To Delete This Location?", ConfirmReasonForDeletionFunction, 280, 100, null, 'Message'); |
} |
} |
function RadGridDiv_RowSelect(sender, eventArgs) { |
var rowindex = eventArgs.get_itemIndexHierarchical(); |
document.getElementById("RadGridDivRowIndex").value = eventArgs.get_itemIndexHierarchical(); |
//alert(rowindex); |
} |
function RadContextMenuDiv_ItemClientClick(sender, args) { |
document.getElementById("<%=txtMenuMode.ClientID%>").value = args.get_item().get_text(); |
if (args.get_item().get_text() == "Delete") { |
args.set_cancel(true); |
lastClickedItem = args.get_item(); |
radconfirm("Are You Sure, You Want To Delete This Department?", ConfirmReasonForDeletionFunction, 280, 100, null, 'Message'); |
} |
var menu = $find("<%=RadContextMenuDiv.ClientID %>"); |
menu.hide(); |
} |
function RadGridDiv_RowContextMenu(sender, eventArgs) { |
document.getElementById("RadGridDivRowIndex").value = eventArgs.get_itemIndexHierarchical(); |
var menu = $find("<%=RadContextMenuDiv.ClientID %>"); |
menu.show(eventArgs.get_domEvent()); |
} |
lastClickedItem = null; |
var clickCalledAfterRadconfirm = false; |
function ConfirmReasonForDeletionFunction(args) { |
if (args) { |
radprompt('Enter Reason ', ConfirmPromptReasonForDeletionFunction, 330, 160, null, 'Reason', ''); |
return false; |
} |
else |
clickCalledAfterRadconfirm = false; |
lastClickedItem = null; |
} |
function ConfirmPromptReasonForDeletionFunction(args) { |
if (args.trim()) { |
clickCalledAfterRadconfirm = true; |
document.getElementById("<%=txtReason.ClientID%>").value = args; |
document.getElementById("<%=btnDivDelete.ClientID%>").click(); |
return true; |
} |
else if (args.trim() != null) { |
clickCalledAfterRadconfirm = false; |
radalert('Error: Enter Reason', null, 100, "Error"); |
} |
lastClickedItem = null; |
} |
</script> |
</telerik:RadScriptBlock> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager ID="ScriptManager1" runat="server"> |
</telerik:RadScriptManager> |
<%--<Ctrl:HeaderV2 ID="Header" runat="server" NavigationLanguage="C#" />--%> |
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadGridDiv"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGridDiv" LoadingPanelID="LoadingPanel1" /> |
<%--<telerik:AjaxUpdatedControl ControlID="rwmMessageBox" />--%> |
</UpdatedControls> |
</telerik:AjaxSetting> |
<telerik:AjaxSetting AjaxControlID="RadContextMenuDiv"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGridDiv" LoadingPanelID="LoadingPanel1" /> |
<telerik:AjaxUpdatedControl ControlID="rwmMessageBox" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
<telerik:AjaxSetting AjaxControlID="btnDivDelete"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGridDiv" LoadingPanelID="LoadingPanel1" /> |
<telerik:AjaxUpdatedControl ControlID="rwmMessageBox" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
<table border="0" cellpadding="0" cellspacing="0" width="100%"> |
<tbody> |
<tr> |
<%--<Ctrl:Left ID="Left1" runat="server" NavigationLanguage="C#" />--%> |
<td > |
<table width="100%" cellpadding="5px"> |
<tr> |
<td> |
<telerik:RadGrid ID="RadGridDiv" runat="server" AutoGenerateColumns="false" AllowSorting="true" |
AllowPaging="true" Skin="ImpetusBlue" AllowFilteringByColumn="true" |
Width="450px" Height="250px" PageSize="5" EnableEmbeddedSkins="false" ImagesPath="~/ImpetusBlue/Grid/" |
OnNeedDataSource="RadGridDiv_NeedDataSource" OnItemCommand="RadGridDiv_ItemCommand" |
OnItemDataBound="RadGridDiv_ItemDataBound" OnUpdateCommand="RadGridDiv_UpdateCommand" |
OnInsertCommand="RadGridDiv_InsertCommand" OnInit="RadGridDiv_Init"> |
<ClientSettings> |
<ClientEvents OnRowContextMenu="RadGridDiv_RowContextMenu" OnRowSelected="RadGridDiv_RowSelect" /> |
<Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" /> |
<Selecting AllowRowSelect="true" /> |
</ClientSettings> |
<PagerStyle Mode="Slider" AlwaysVisible="true" /> |
<MasterTableView AutoGenerateColumns="false" EditMode="EditForms" CommandItemDisplay="Bottom" |
Width="100%" DataKeyNames="DepartmentCode" CommandItemSettings-AddNewRecordText="Add New Department"> |
<CommandItemTemplate> |
<div> |
<table width="103%" border="0" cellpadding="0" cellspacing="0" style="margin-top: -2px; |
margin-left: -4px; margin-bottom: -3px;"> |
<tr> |
<telerik:RadToolBar runat="server" ID="RTBDiv" Skin="Office2007" Width="100%" |
OnButtonClick="RTBDiv_ButtonClick" OnClientButtonClicked="RTBDivclientButtonClicked"><%----%> |
<Items> |
<telerik:RadToolBarButton Text="Add" Font-Size="9" ForeColor="#00156E" CommandName="InitInsert" |
ImagePosition="Left" ImageUrl="images/neww1.gif"> |
</telerik:RadToolBarButton> |
<telerik:RadToolBarButton Text="Edit" Font-Size="9" ForeColor="#00156E" CommandName="Edit" ImagePosition="Left" |
ImageUrl="images/penedit.png"> |
</telerik:RadToolBarButton> |
<telerik:RadToolBarButton Text="Delete" Font-Size="9" ForeColor="#00156E" ImagePosition="Left" CommandName="Delete" |
ImageUrl="images/delneeewww.gif" > |
</telerik:RadToolBarButton> |
<telerik:RadToolBarButton Text="Close" Font-Size="9" ForeColor="#00156E" ImagePosition="Left" |
ImageUrl="images/closeeeeeee.gif"> |
</telerik:RadToolBarButton> |
<telerik:RadToolBarButton Text="Text" Width="200px" Font-Size="9" ForeColor="#00156E" PostBack="false"> |
</telerik:RadToolBarButton> |
</Items> |
</telerik:RadToolBar> |
</tr> |
</table> |
</div> |
</CommandItemTemplate> |
<Columns> |
<%-- <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> |
<ItemStyle HorizontalAlign="Center" Width="7%" /> |
</telerik:GridEditCommandColumn>--%> |
<telerik:GridBoundColumn UniqueName="DepartmentCode" DataField="DepartmentCode" HeaderText="DepartmentCode" |
Visible="false" ReadOnly="true"> |
</telerik:GridBoundColumn> |
<%--<telerik:GridBoundColumn UniqueName="DepartmentShortDesc" DataField="DepartmentShortDesc" |
HeaderText="Department Short Description"> |
</telerik:GridBoundColumn>--%> |
<telerik:GridTemplateColumn UniqueName="DepartmentShortDesc" DataField="DepartmentShortDesc" |
HeaderText="Short Description" HeaderStyle-Width="25%" ItemStyle-Width="25%" FilterControlWidth="50%" |
SortExpression="DepartmentShortDesc"> |
<ItemTemplate> |
<asp:Label ID="LblDepartmentShortDesc" Text='<%#Eval("DepartmentShortDesc")%>' runat="server"></asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadTextBox ID="txtDepartmentShortDesc" TextMode="SingleLine" MaxLength="5" EnableEmbeddedSkins="false" |
Text='<%#Bind("DepartmentShortDesc")%>' runat="server" ToolTip="Maximum Character Allowed is 5"> |
</telerik:RadTextBox><asp:Label ID="Label1" runat="server" ForeColor="Red" Text="*"></asp:Label> |
<asp:RequiredFieldValidator ID="RequiredFieldValidatorDepartmentShortDesc" runat="server" |
Display="Dynamic" ErrorMessage="Short Description Cannot Be Empty" ControlToValidate="txtDepartmentShortDesc"></asp:RequiredFieldValidator> |
<asp:Label ID="Msg" runat="server" ForeColor="Red"></asp:Label> |
<asp:RegularExpressionValidator ID="RegularExpressionValidatorDepartmentShortDesc" |
runat="server" Display="Dynamic" ControlToValidate="txtDepartmentShortDesc" ValidationExpression="^[a-zA-Z0-9]+$" |
ErrorMessage="Special Characters not Allowed"></asp:RegularExpressionValidator> |
<telerik:RadTextBox runat="server" EnableEmbeddedSkins="false" ID="txtDepartmentCode" Text='<%# Eval("DepartmentCode") %>' |
Style="display: none;"> |
</telerik:RadTextBox> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<%--<telerik:GridBoundColumn UniqueName="DepartmentName" DataField="DepartmentName" HeaderText="Department Name"> |
</telerik:GridBoundColumn>--%> |
<telerik:GridTemplateColumn UniqueName="DepartmentName" DataField="DepartmentName" |
HeaderText="Name" SortExpression="DepartmentName" HeaderStyle-Width="75%" ItemStyle-Width="75%" > |
<ItemTemplate> |
<asp:Label ID="LblDepartmentName" Text='<%#Eval("DepartmentName")%>' runat="server"></asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadTextBox ID="txtDepartmentName" TextMode="SingleLine" MaxLength="50" Text='<%#Bind("DepartmentName")%>' |
runat="server" EnableEmbeddedSkins="false"> |
</telerik:RadTextBox><asp:Label ID="Label2" runat="server" ForeColor="Red" Text="*"></asp:Label> |
<asp:RequiredFieldValidator ID="RequiredFieldValidatorDepartmentName" runat="server" |
ErrorMessage="Name Cannot Be Empty" ControlToValidate="txtDepartmentName" Display="Dynamic"></asp:RequiredFieldValidator> |
<%--<asp:RegularExpressionValidator ID="RegularExpressionValidatorDepartmentName" runat="server" |
ControlToValidate="txtDepartmentName" ValidationExpression="^[a-zA-Z0-9 ]+$" ErrorMessage="Special Characters not Allowed"></asp:RegularExpressionValidator>--%> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<%--<telerik:GridCheckBoxColumn UniqueName="Active" DataField="Active" HeaderText="Active" HeaderStyle-HorizontalAlign="Center"> |
<ItemStyle HorizontalAlign="Center" Width="8%" /> |
</telerik:GridCheckBoxColumn>--%> |
<%--<telerik:GridBoundColumn UniqueName="CreatedBy" DataField="CreatedBy" HeaderText="Created By" |
Visible="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn UniqueName="CreatedOn" DataField="CreatedOn" HeaderText="Created On" |
Visible="false"> |
<EditItemTemplate> |
<telerik:RadDatePicker ID="RadDateTimePickerCreatedOn" runat="server" Skin="Office2007" |
DbSelectedDate='<%#Bind("CreatedOn")%>'> |
<DateInput ID="DateInputCreatedOn" DateFormat="dd MMM yy" runat="server"> |
</DateInput> |
</telerik:RadDatePicker> |
<asp:RequiredFieldValidator ID="RequiredFieldValidatorCreatedOn" runat="server" ErrorMessage="*" |
ControlToValidate="RadDateTimePickerCreatedOn"></asp:RequiredFieldValidator> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn UniqueName="ModifiedBy" DataField="ModifiedBy" HeaderText="Modified By" |
Visible="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn UniqueName="ModifiedOn" DataField="ModifiedOn" HeaderText="Modified On" |
Visible="false"> |
<EditItemTemplate> |
<telerik:RadDatePicker ID="RadDateTimePickerModifiedOn" runat="server" Skin="Office2007" |
DbSelectedDate='<%#Bind("ModifiedOn")%>'> |
<DateInput ID="DateInputModifiedOn" DateFormat="dd MMM yy" runat="server"> |
</DateInput> |
</telerik:RadDatePicker> |
<asp:RequiredFieldValidator ID="RequiredFieldValidatorModifiedOn" runat="server" |
ErrorMessage="*" ControlToValidate="RadDateTimePickerModifiedOn"></asp:RequiredFieldValidator> |
</EditItemTemplate> |
</telerik:GridTemplateColumn>--%> |
<%--<telerik:GridButtonColumn ConfirmText="Delete this Department?" ButtonType="ImageButton" |
ConfirmDialogType="RadWindow" ConfirmTitle="Delete" CommandName="Delete" Text="Delete" |
UniqueName="DeleteColumn"> |
<ItemStyle HorizontalAlign="Center" Width="30px" /> |
</telerik:GridButtonColumn>--%> |
</Columns> |
<EditFormSettings> |
<%--<PopUpSettings Width="80%" />--%> |
<%--<FormMainTableStyle Width="100%" /> --%> |
<FormTableStyle Width="100%" /> |
<FormStyle Width="100%" BackColor="White" /> |
<FormCaptionStyle Font-Bold="true"/> |
<EditColumn ButtonType="ImageButton"></EditColumn> |
</EditFormSettings> |
<NoRecordsTemplate> |
<center> |
No Records Found!!!</center> |
</NoRecordsTemplate> |
</MasterTableView> |
</telerik:RadGrid> |
<asp:Label ID="lblMsg" runat="server" ForeColor="White" Text="Impetus" ></asp:Label> |
</td> |
</tr> |
</table> |
<telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel1" IsSticky="true" Style="margin-top: 120px; |
margin-left: 310px; position: absolute; z-index: 100" Transparency="30" HorizontalAlign="Center" |
MinDisplayTime="500" BackColor="#E0E0E0"> |
<asp:Image runat="server" ID="LoadingImage1" ImageUrl="~/iSmart/images/Loading.gif" |
AlternateText="Loading..." /> |
</telerik:RadAjaxLoadingPanel> |
<telerik:RadWindowManager VisibleTitlebar="true" VisibleStatusbar="false" RestrictionZoneID="RestrictionZone" |
Width="644px" Height="98%" Modal="true" ID="rwmMessageBox" Skin="Office2007" runat="server" |
DestroyOnClose="true" Behaviors="Close, Move, Resize"> |
</telerik:RadWindowManager> |
<telerik:RadContextMenu ID="RadContextMenuDiv" runat="server" Skin="Office2007" OnItemClick="RadContextMenuDiv_ItemClick" |
OnClientItemClicking="RadContextMenuDiv_ItemClientClick"> |
<Items> |
<telerik:RadMenuItem Text="Add" Value="Add" /> |
<telerik:RadMenuItem Text="Edit" Value="Edit" /> |
<telerik:RadMenuItem Text="Delete" Value="Delete" /> |
</Items> |
</telerik:RadContextMenu> |
<asp:Button ID="btnDivDelete" runat="server" OnClick="btnDivDelete_Click" Style="display: none;" /> |
<input type="hidden" id="RadGridDivRowIndex" name="RadGridDivRowIndex" /> |
<asp:TextBox ID="txtReason" runat="server" Text="0" Style="display: none;"></asp:TextBox> |
<asp:TextBox ID="txtMenuMode" runat="server" Text="0" Style="display: none;"></asp:TextBox> |
</td> |
</tr> |
</tbody> |
</table> |
</form> |
</body> |
</html> |
Here is the .cs page too.
using System; |
using System.Collections; |
using System.Configuration; |
using System.Data; |
using System.Linq; |
using System.Web; |
using System.Web.Security; |
using System.Web.UI; |
using System.Web.UI.HtmlControls; |
using System.Web.UI.WebControls; |
using System.Web.UI.WebControls.WebParts; |
using System.Xml.Linq; |
using Telerik.Web.UI; |
using iSmart.BLayer; |
namespace iSmart |
{ |
public partial class Department : System.Web.UI.Page |
{ |
iSmartBLayer BL = new iSmartBLayer(); |
private String UserId; |
private String CompanyID; |
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!IsPostBack) |
{ |
if (Session["AuthenticatedUser"] == null) |
Response.Redirect("~/Admin/LoginCS.aspx"); |
else |
{ |
UserId = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID; |
CompanyID = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).CompanyID; |
Session["Message"] = ""; |
} |
//UserId = "55"; |
//CompanyID ="8"; |
// dsiSmartDiv.SelectParameters[0].DefaultValue = CompanyID.ToString(); |
} |
UserId = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).UserID; |
CompanyID = ((ProductAdmin.AuthenticatedUser)Session["AuthenticatedUser"]).CompanyID; |
} |
protected void RadGridDiv_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
{ |
//CompanyID = "9"; |
RadGridDiv.DataSource = BL.getDivision(CompanyID); |
} |
protected void btnDivDelete_Click(object sender, EventArgs e) |
{ |
String DeleteMessage = String.Empty; |
int RadGridDivRowIndex; |
RadGridDivRowIndex = Convert.ToInt32(Request.Form["RadGridDivRowIndex"]); |
String DepartmentShortDesc, Reason, DepartmentCode; |
DepartmentCode = RadGridDiv.MasterTableView.Items[RadGridDivRowIndex]["DepartmentCode"].Text; |
DepartmentShortDesc = ((Label)RadGridDiv.MasterTableView.Items[RadGridDivRowIndex]["DepartmentShortDesc"].FindControl("LblDepartmentShortDesc")).Text; |
Reason = txtReason.Text; |
try |
{ |
Int32 IDD = BL.DeleteDivision( |
DepartmentCode, |
Reason, |
UserId, |
CompanyID |
); |
if (IDD == -1) |
{ |
DeleteMessage = "Some Internal Problem on Deleting the Data. Try Again later"; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + DeleteMessage, "Warning", 390, 160); |
UDFDisplayMessage(DeleteMessage); |
} |
else if (IDD == -2) |
{ |
DeleteMessage = "Error : [" + DepartmentShortDesc + "] has Reference with Another Table. So Your Not Allowed to Delete"; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + DeleteMessage + "&Imageurl=-1", "Error", 390, 170); |
UDFDisplayMessage(DeleteMessage); |
} |
else |
{ |
DeleteMessage = "[" + DepartmentShortDesc + "] Deleted Successfully"; |
RadGridDiv.Rebind(); |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + DeleteMessage + "&Imageurl=1", "Success", 390, 160); |
UDFDisplayMessage(DeleteMessage); |
} |
} |
catch (Exception ex) |
{ |
DeleteMessage = "Warning : " + ex.Message; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + DeleteMessage, "Warning", 390, 160); |
UDFDisplayMessage(DeleteMessage); |
} |
Session["Message"] = DeleteMessage; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + DeleteMessage + "&Imageurl=Images/images.jpeg", "Alert", 390, 160); |
} |
protected void RadGridDiv_Init(object sender, EventArgs e) |
{ |
GridFilterMenu menu = RadGridDiv.FilterMenu; |
int i = 0; |
while (i < menu.Items.Count) |
{ |
if (menu.Items[i].Text == "NoFilter" || |
menu.Items[i].Text == "Contains" || |
menu.Items[i].Text == "DoesNotContain" || |
menu.Items[i].Text == "StartsWith" || |
menu.Items[i].Text == "EndsWith") |
{ |
i++; |
} |
else |
{ |
menu.Items.RemoveAt(i); |
} |
} |
} |
protected void RTBDiv_ButtonClick(object sender, RadToolBarEventArgs e) |
{ |
String PageClicked = e.Item.Text; |
int RadGridDivRowIndex; |
switch (e.Item.Text) |
{ |
case "Add": |
RadGridDiv.MasterTableView.IsItemInserted = true; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionDataField = ""; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionFormatString = "Add New Department"; |
RadGridDiv.Rebind(); |
break; |
case "Edit": |
if (Request.Form["RadGridDivRowIndex"].Trim() != "" && Request.Form["RadGridDivRowIndex"] != null) |
{ |
RadGridDivRowIndex = Convert.ToInt32(Request.Form["RadGridDivRowIndex"]); |
RadGridDiv.MasterTableView.Items[RadGridDivRowIndex].Edit = true; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionDataField = "DepartmentShortDesc"; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionFormatString = "Edit Department : {0}"; |
RadGridDiv.Rebind(); |
} |
break; |
case "Delete": |
break; |
case "Close": |
break; |
} |
} |
protected void RadContextMenuDiv_ItemClick(object sender, RadMenuEventArgs e) |
{ |
int RadGridDivRowIndex; |
RadGridDivRowIndex = Convert.ToInt32(Request.Form["RadGridDivRowIndex"]); |
switch (e.Item.Value) |
{ |
case "Edit": |
RadGridDiv.MasterTableView.Items[RadGridDivRowIndex].Edit = true; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionDataField = "DepartmentShortDesc"; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionFormatString = "Edit Department : {0}"; |
RadGridDiv.Rebind(); |
break; |
case "Add": |
RadGridDiv.MasterTableView.IsItemInserted = true; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionDataField = ""; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionFormatString = "Add New Department"; |
RadGridDiv.Rebind(); |
break; |
case "Delete": |
break; |
} |
} |
protected void RadGridDiv_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "Edit") |
{ |
RadGridDiv.MasterTableView.EditFormSettings.CaptionDataField = "DepartmentShortDesc"; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionFormatString = "Edit Department : {0}"; |
} |
else if (e.CommandName == "InitInsert") |
{ |
RadGridDiv.MasterTableView.EditFormSettings.CaptionDataField = ""; |
RadGridDiv.MasterTableView.EditFormSettings.CaptionFormatString = "Add New Department"; |
} |
} |
protected void RadGridDiv_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) |
{ |
if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
{ |
GridEditableItem item = (GridEditableItem)e.Item; |
//((System.Web.UI.WebControls.TableRow)(item.Controls[1].Controls[0].Controls[1].Controls[0].Controls[0])).Visible = false; |
} |
if (e.Item is GridCommandItem) |
{ |
GridCommandItem Item = (GridCommandItem)e.Item; |
RadToolBar rtb = (RadToolBar)Item.FindControl("RTBDiv"); |
rtb.Items[4].Text = Session["Message"].ToString(); |
} |
} |
protected void saveDivision(String DepartmentCode, String DepartmentShortDesc, String DepartmentName, GridCommandEventArgs e) |
{ |
String Message = String.Empty; |
try |
{ |
Int32 ID = BL.saveDivision( |
DepartmentCode, |
DepartmentShortDesc.Trim(), |
DepartmentName.Trim(), |
//Convert.ToInt16(Active).ToString(), |
UserId, |
CompanyID |
); |
if (ID == -1) |
{ |
Message = "Some Internal Problem on Saving the Data. Try Again later"; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + Message, "Warning", 390, 160); |
UDFDisplayMessage(Message); |
} |
else if (ID == -2) |
{ |
Message = "Error : Data Duplication. Short Description [" + DepartmentShortDesc + "] Already Exists"; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + Message + "&Imageurl=-1", "Error", 390, 160); |
UDFDisplayMessage(Message); |
} |
else if (ID == -3) |
{ |
Message = "Error : Data Duplication. Department Name [" + DepartmentName + "] Already Exists"; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + Message + "&Imageurl=-1", "Error", 390, 160); |
UDFDisplayMessage(Message); |
} |
else if (ID == Convert.ToInt16(DepartmentCode)) |
{ |
Message = "[" + DepartmentShortDesc + "] Updated Successfully "; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + Message + "&Imageurl=1", "Success", 390, 160); |
UDFDisplayMessage(Message); |
} |
else |
{ |
e.Canceled = true; |
e.Item.Edit = false; |
Message = "[" + DepartmentShortDesc + "] Saved Successfully "; |
Session["Message"] = Message; |
RadGridDiv.Rebind(); |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + Message + "&Imageurl=1", "Success", 390, 160); |
UDFDisplayMessage(Message); |
} |
} |
catch (Exception ex) |
{ |
Message = "Warning : " + ex.Message; |
e.Canceled = true; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + Message, "Warning", 390, 160); |
UDFDisplayMessage(Message); |
} |
Session["Message"] = Message; |
//openRadWindow(rwmMessageBox, "MyMessageBox.aspx?Message=" + Message, "Alert", 390, 160); |
} |
protected void openRadWindow(RadWindowManager rwmTemp, string FileName, String Title, Int32 Width, Int32 Height) |
{ |
//iSmartBLayer bl = new iSmartBLayer(); |
BL.openRadWindow(rwmTemp, FileName, Title, Width, Height); |
} |
protected void RadGridDiv_InsertCommand(object source, GridCommandEventArgs e) |
{ |
//dsiSmartDiv.InsertParameters[0].DefaultValue = CompanyID.ToString(); |
//dsiSmartDiv.InsertParameters[1].DefaultValue = UserId; |
GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; |
Hashtable newValues = new Hashtable(); |
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, insertedItem); |
saveDivision( |
"0", |
((RadTextBox)insertedItem.FindControl("txtDepartmentShortDesc")).Text, |
((RadTextBox)insertedItem.FindControl("txtDepartmentName")).Text, |
e |
); |
//GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; |
//Hashtable newValues = new Hashtable(); |
//e.Item.OwnerTableView.ExtractValuesFromItem(newValues, insertedItem); |
//int value = 0; |
//RadTextBox txt = (RadTextBox)e.Item.FindControl("txtDepartmentShortDesc"); |
//int Rowcount = RadGridDiv.Items.Count; |
//for (int count = 0; Rowcount > count; count++) |
//{ |
// Label lbl = (Label)RadGridDiv.Items[count].FindControl("LblDivisionShortDesc"); |
// if (txt.Text.ToUpper() == lbl.Text.ToUpper()) |
// { |
// value++; |
// } |
//} |
//if (value == 0) |
//{ |
// dsiSmartDiv.InsertParameters[0].DefaultValue = CompanyID.ToString(); |
// dsiSmartDiv.InsertParameters[1].DefaultValue = UserId; |
//} |
//else |
//{ |
// Label lbl = (Label)e.Item.FindControl("Msg"); |
// lbl.Text = "Already Exists"; |
// e.Canceled = true; |
//} |
} |
protected void RadGridDiv_UpdateCommand(object source, GridCommandEventArgs e) |
{ |
GridEditFormItem updatedItem = (GridEditFormItem)e.Item; |
Hashtable newValues = new Hashtable(); |
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, updatedItem); |
saveDivision( |
((RadTextBox)updatedItem.FindControl("txtDepartmentCode")).Text, |
((RadTextBox)updatedItem.FindControl("txtDepartmentShortDesc")).Text, |
((RadTextBox)updatedItem.FindControl("txtDepartmentName")).Text, |
e |
); |
//dsiSmartDiv.UpdateParameters[0].DefaultValue = UserId; |
//GridEditFormItem insertedItem = (GridEditFormItem)e.Item; |
//Hashtable newValues = new Hashtable(); |
//e.Item.OwnerTableView.ExtractValuesFromItem(newValues, insertedItem); |
//int value = 0; |
//RadTextBox txt = (RadTextBox)e.Item.FindControl("txtDepartmentShortDesc"); |
//int Rowcount = RadGridDiv.Items.Count; |
//for (int count = 0; Rowcount > count; count++) |
//{ |
// Label lbl = (Label)RadGridDiv.Items[count].FindControl("LblDepartmentShortDesc"); |
// if (txt.Text.ToUpper() == lbl.Text.ToUpper()) |
// { |
// value++; |
// } |
//} |
//if (value == 0) |
//{ |
// dsiSmartDiv.UpdateParameters[0].DefaultValue = UserId; |
//} |
//else if (value == 1) |
//{ |
// Label LBL = (Label)RadGridDiv.MasterTableView.Items[e.Item.ItemIndex].FindControl("LblDepartmentShortDesc"); |
// if (LBL.Text.ToUpper() == txt.Text.ToUpper()) |
// { |
// dsiSmartDiv.UpdateParameters[0].DefaultValue = UserId; |
// } |
// else |
// { |
// Label lbl = (Label)e.Item.FindControl("Msg"); |
// lbl.Text = "Already Exists"; |
// e.Canceled = true; |
// } |
//} |
//else |
//{ |
// Label lbl = (Label)e.Item.FindControl("Msg"); |
// lbl.Text = "Already Exists"; |
// e.Canceled = true; |
//} |
} |
private void UDFDisplayMessage(string text) |
{ |
RadGridDiv.Controls.Add(new LiteralControl(string.Format("<span style='font-weight: bold; color: red;'>{0}</span>", text))); |
} |
} |
} |
Is there any option to rectify this.
-Anto