Dear Telerik team,
I have several text and combo boxes and i use them to insert new rows into grid.
1. The column button "Delete" in grid, it is not working.
2. I want to convert the values in footer total to format string "{0:N2}" (ex. $5,000.00).
3. When i create a row, the footer total is double x2 (Capture1). If i reload the page, the footer total is correct (Capture2).
Can you please help me?
Bellow you will find my VB code.
Thank you in advance for you time.
Best Regards,
Navarino Technology Department.
I have several text and combo boxes and i use them to insert new rows into grid.
1. The column button "Delete" in grid, it is not working.
2. I want to convert the values in footer total to format string "{0:N2}" (ex. $5,000.00).
3. When i create a row, the footer total is double x2 (Capture1). If i reload the page, the footer total is correct (Capture2).
Can you please help me?
Bellow you will find my VB code.
Thank you in advance for you time.
Best Regards,
Navarino Technology Department.
Protected
Sub
btnCreateRates_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
btnCreateRates.Click
If
txtCards.Text =
Nothing
Then
MsgBox(
"Please type number of cards, in order to continue."
, MsgBoxStyle.OkOnly,
"ERROR"
)
Exit
Sub
Else
'Confirmation()
dtValues =
DirectCast
(Session(
"tblPendingOrders"
), DataTable)
' retrieve DataTable from session
Dim
drValues
As
DataRow = dtValues.NewRow()
GridID = grdData.MasterTableView.Items.Count + 1
drValues(
"ID"
) = GridID
drValues(
"Address1"
) = txtAddress1.Text
drValues(
"Address2"
) = txtAddress2.Text
drValues(
"Address3"
) = txtAddress3.Text
drValues(
"Cards"
) = txtCards.Value
drValues(
"CardType"
) =
"Virtual"
drValues(
"CareOf"
) = txtCareOf.Text
drValues(
"Charge"
) = txtCards.Value * GetCharge()
drValues(
"City"
) = txtCity.Text
drValues(
"Country"
) = txtCountry.Text
drValues(
"MasterOf"
) = cbVessels.SelectedItem.Text
drValues(
"Notes"
) = txtNotes.Text
drValues(
"OrderRef"
) = txtOrderRef.Text
drValues(
"Owning"
) = txtOwning.Text
drValues(
"Price"
) = GetCharge()
drValues(
"Provider"
) = cbProviders.SelectedItem.Text
drValues(
"Units"
) = cbUnits.SelectedItem.Text
drValues(
"Vessel"
) = cbVessels.SelectedItem.Text
drValues(
"VesselID"
) = cbVessels.SelectedValue
drValues(
"ZipCode"
) = txtZipCode.Text
dtValues.Rows.Add(drValues)
dtValues.AcceptChanges()
Session(
"tblPendingOrders"
) = dtValues
'store DataTable in session
grdData.Rebind()
grdData.MasterTableView.IsItemInserted =
False
grdData.MasterTableView.Rebind()
lblPendingOrders.Text =
"Pending CCC Orders: "
& grdData.MasterTableView.Items.Count
End
If
End
Sub
Protected
Sub
grdData_ItemDeleted(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridDeletedEventArgs)
Handles
grdData.ItemDeleted
Dim
item
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
Dim
id
As
String
= item.GetDataKeyValue(
"ID"
).ToString()
If
Not
e.Exception
Is
Nothing
Then
e.ExceptionHandled =
True
SetMessage(
"Product with ID "
+ id +
" cannot be deleted. Reason: "
+ e.Exception.Message)
Else
SetMessage(
"Product with ID "
+ id +
" is deleted!"
)
End
If
End
Sub
Private
Sub
SetMessage(
ByVal
message
As
String
)
gridMessage = message
End
Sub
Protected
Sub
grdData_NeedDataSource(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
grdData.NeedDataSource
dtValues =
New
DataTable()
dtValues.Columns.Add(
"ID"
)
dtValues.Columns.Add(
"CardType"
)
dtValues.Columns.Add(
"Provider"
)
dtValues.Columns.Add(
"Vessel"
)
dtValues.Columns.Add(
"VesselID"
)
dtValues.Columns.Add(
"Units"
)
dtValues.Columns.Add(
"Cards"
)
dtValues.Columns.Add(
"Price"
)
dtValues.Columns.Add(
"Charge"
)
dtValues.Columns.Add(
"Address1"
)
dtValues.Columns.Add(
"Address2"
)
dtValues.Columns.Add(
"Address3"
)
dtValues.Columns.Add(
"CareOf"
)
dtValues.Columns.Add(
"City"
)
dtValues.Columns.Add(
"Country"
)
dtValues.Columns.Add(
"MasterOf"
)
dtValues.Columns.Add(
"Notes"
)
dtValues.Columns.Add(
"OrderRef"
)
dtValues.Columns.Add(
"Owning"
)
dtValues.Columns.Add(
"ZipCode"
)
If
Session(
"tblPendingOrders"
) IsNot
Nothing
Then
' retrieve DataTable from session
dtValues =
DirectCast
(Session(
"tblPendingOrders"
), DataTable)
End
If
grdData.DataSource = dtValues
Session(
"tblPendingOrders"
) = dtValues
End
Sub
Protected
Sub
grdData_ItemDataBound(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
grdData.ItemDataBound
If
TypeOf
e.Item
Is
GridHeaderItem
Then
Dim
header
As
GridHeaderItem =
DirectCast
(e.Item, GridHeaderItem)
End
If
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
dataItem
As
GridDataItem =
CType
(e.Item, GridDataItem)
Price += dataItem(
"Price"
).Text
Charge += dataItem(
"Charge"
).Text
Cards += dataItem(
"Cards"
).Text
End
If
If
(
TypeOf
e.Item
Is
GridFooterItem)
Then
Dim
footerItem
As
GridFooterItem =
CType
(e.Item, GridFooterItem)
footerItem(
"Price"
).Text = Price
footerItem(
"Charge"
).Text = Charge
footerItem(
"Cards"
).Text = Cards
footerItem(
"Provider"
).Controls.Add(
New
LiteralControl(
"<span style='color: Black; font-weight: bold;'>Totals:</span> "
))
End
If
End
Sub