i need 2 clarification
1.
i need to give notification using popup window instead of alert. is there any control to implement popup.
2.
i am having a Business Object Named Customer. i am binding the customer collection to RadGridView. i need to add the new row on top of the gridview. i have given the code
1.
i need to give notification using popup window instead of alert. is there any control to implement popup.
2.
i am having a Business Object Named Customer. i am binding the customer collection to RadGridView. i need to add the new row on top of the gridview. i have given the code
<
Grid
>
<
telerik:RadGridView
AutoGenerateColumns
=
"False"
EditTriggers
=
"F2"
HorizontalAlignment
=
"Left"
Name
=
"rgrdCustomer"
RowIndicatorVisibility
=
"Visible"
VerticalAlignment
=
"Top"
AddingNewDataItem
=
"rgrdCustomer_AddingNewDataItem"
Deleting
=
"rgrdCustomer_Deleting"
RowEditEnded
=
"rgrdCustomer_RowEditEnded"
RowValidating
=
"rgrdCustomer_RowValidating"
ActionOnLostFocus
=
"CancelEdit"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding CustomerID}"
Header
=
"ID"
IsReadOnly
=
"True"
Width
=
"50"
IsFilterable
=
"False"
IsGroupable
=
"False"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding CustomerName}"
Header
=
"CustomerName*"
Width
=
"250"
IsFilterable
=
"False"
IsGroupable
=
"False"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding OpeningBalance}"
Header
=
"OpeningBalance"
DataFormatString
=
"{} {0:##,##,##0.00}"
Width
=
"100"
TextAlignment
=
"Right"
IsResizable
=
"False"
IsFilterable
=
"False"
IsGroupable
=
"False"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding ContactNumber}"
Header
=
"ContactNumber"
Width
=
"100"
IsResizable
=
"False"
IsFilterable
=
"False"
IsGroupable
=
"False"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
Grid
>
class CustomerBO
{
#region Fields
private int _CustomerID;
private string _CustomerName;
private decimal _OpeningBalance;
private string _ContactNumber;
#endregion
#region Properties
public int CustomerID
{
get { return _CustomerID; }
set { _CustomerID = value; }
}
public string CustomerName
{
get { return _CustomerName; }
set { _CustomerName = value; }
}
public decimal OpeningBalance
{
get { return _OpeningBalance; }
set { _OpeningBalance = value; }
}
public string ContactNumber
{
get { return _ContactNumber; }
set { _ContactNumber = value; }
}
#endregion
}
public partial class CustomerView : UserControl
{
public CustomerView()
{
InitializeComponent();
}
private void rgrdCustomer_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
e.NewObject = new CustomerBO();
}
private void rgrdCustomer_Deleting(object sender, Telerik.Windows.Controls.GridViewDeletingEventArgs e)
{
CustomerDAL customerdata = new CustomerDAL();
if (e.Items.Count() != 1)
{
Notification.ErrorMessage("More than one Customer Selected");
}
else
{
foreach (CustomerBO customer in e.Items)
{
customerdata.Delete(customer.CustomerID);
Notification.InformationMessage("Deleted Sucessfully");
}
}
}
private void rgrdCustomer_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
{
if (e.EditAction == GridViewEditAction.Cancel)
{
return;
}
try
{
if (e.EditOperationType == GridViewEditOperationType.Insert)
{
CustomerDAL customerdata = new CustomerDAL();
CustomerBO customerentity = (CustomerBO)e.NewData;
customerdata.Insert(customerentity);
this.LoadData();
Notification.InformationMessage("Added Successfully");
}
if (e.EditOperationType == GridViewEditOperationType.Edit)
{
CustomerDAL customerdata = new CustomerDAL();
customerdata.Update((CustomerBO)e.NewData);
Notification.InformationMessage("Updated Successfully");
}
this.LoadData();
}
catch (Exception ex)
{
Notification.ErrorMessage(ex.Message);
}
}
private void rgrdCustomer_RowValidating(object sender, Telerik.Windows.Controls.GridViewRowValidatingEventArgs e)
{
CustomerBO customer = e.Row.DataContext as CustomerBO;
if (String.IsNullOrEmpty(customer.CustomerName) || customer.CustomerName.Length > 50)
{
RowValidation.Validate("CustomerName", "Fill the Customer Name", e);
}
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
this.LoadData();
this.rgrdCustomer.Focus();
}
private void LoadData()
{
CustomerDAL customerdata = new CustomerDAL();
this.rgrdCustomer.ItemsSource = customerdata.FetchAll();
}
}