8 Answers, 1 is accepted
0

w
Top achievements
Rank 1
answered on 19 Mar 2012, 12:42 PM
Anybody reply my problem? thanks.
0

Elliott
Top achievements
Rank 2
answered on 19 Mar 2012, 02:41 PM
you need to provide a bit more data (and some code would be nice)
server or client side binding?
do you have a edit column - and have you specified where the Add New Record goes?
if yes to both, then the ItemCommand event on the server has a CommandName property of the event args which you can interrogate in code
or do you want to do everything on the client?
server or client side binding?
do you have a edit column - and have you specified where the Add New Record goes?
if yes to both, then the ItemCommand event on the server has a CommandName property of the event args which you can interrogate in code
or do you want to do everything on the client?
0

w
Top achievements
Rank 1
answered on 19 Mar 2012, 03:55 PM
Thanks. I will give you my current background,
I am migrating the GridView to Telerik RadGrid, and in My original Project structure was, GridView ------------> DataTable --------->SQL Server Database, everything done at server side by using binding example as belong Snippets,
My business Logic will monitor dataTable.ColumnChanging event which triggered by gridView.UpdateRow(gridView.EditIndex, False)
to trace every new values inserted or updated to the underlying DataTable object, and put other business logic in between before updating to the SQL Server Database.
Come to the Telerik RadGrid, I have justed replaced to the following coding as,
And, I am not sure the life cycle of the RadGrid 's Binding scheme, how or in what command when the data keyed in at RadGrid save it to the Bindded object DataTable? Any Suggest?
I am migrating the GridView to Telerik RadGrid, and in My original Project structure was, GridView ------------> DataTable --------->SQL Server Database, everything done at server side by using binding example as belong Snippets,
<
asp:GridView
ID
=
"OrderDetailGrid"
runat
=
"server"
DataMember
=
"OrderDetail"
DataSourceID
=
"DBDataSource2"
AutoGenerateColumns
=
"False"
OnRowCommand
=
"DBDataSource1.HandleGridCommand"
DataKeyNames
=
"CompanyID,DivisionID,DepartmentID,OrderNumber,OrderLineNumber"
>
<
Columns
>
<
asp:TemplateField
HeaderStyle-Width
=
"20"
>
<
ItemTemplate
>
<%#Container.DataItemIndex + 1%>
</
ItemTemplate
>
</
asp:TemplateField
>
<
asp:CommandField
EditImageUrl
=
"~/images/edit.gif"
EditText
=
"Edit Ex"
UpdateImageUrl
=
"~/images/update.gif"
UpdateText
=
"Update"
CancelImageUrl
=
"~/images/cancel_edit.gif"
CancelText
=
"Cancel"
ButtonType
=
"Image"
ShowEditButton
=
"True"
>
<
ItemStyle
Width
=
"16px"
/>
</
asp:CommandField
>
<
asp:CommandField
DeleteImageUrl
=
"~/images/delete.gif"
DeleteText
=
"Delete"
ButtonType
=
"Image"
ShowDeleteButton
=
"True"
ShowCancelButton
=
"False"
>
<
ItemStyle
Width
=
"16px"
/>
</
asp:CommandField
>
<
asp:TemplateField
HeaderText="<%$ Translation:Item ID %>" SortExpression="ItemUPCCode" HeaderStyle-Width="130" >
<
ItemTemplate
>
<
asp:Label
ID
=
"lblItemUPCCode"
runat
=
"server"
Text='<%# Eval("ItemUPCCode") %>' Width="100%"></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
Skin
=
"Hay"
ID
=
"RadItemUPCCode"
runat
=
"server"
Text ='<%# Bind("ItemUPCCode") %>' Height ="180" Width="97%"
HighlightTemplatedItems = "true" Sort="Ascending"
OnItemsRequested= 'RadComboBox_ItemRequested' EnableLoadOnDemand ="true" ShowToggleImage="false"
DropDownWidth ="680" ShowMoreResultsBox ="true" EnableVirtualScrolling ="true" AutoPostBack ="true" >
<
HeaderTemplate
>
<
div
>
<
table
border
=
"0"
style
=
"width: 650px;text-align:left"
cellspacing
=
"0"
cellpadding
=
"0"
>
<
tr
>
<
td
style
=
"width: 100px;text-align:left"
>
<
asp:Label
ID
=
"lblItemID2"
runat
=
"server"
Text='<%$ Translation:Item ID %>'></
asp:Label
>
</
td
>
<
td
style
=
"width: 250px;text-align:left"
>
<
asp:Label
ID
=
"lblItemName2"
runat
=
"server"
Text='<%$ Translation:Item Name %>'></
asp:Label
>
</
td
>
<
td
style
=
"width: 80px;text-align:left"
>
<
asp:Label
ID
=
"lblWarehouse1"
runat
=
"server"
Text='<%$ Translation:UOM %>'></
asp:Label
>
</
td
>
<
td
style
=
"width: 60px;text-align:right"
>
<
asp:Label
ID
=
"lblQtyOnHand"
runat
=
"server"
Text='<%$ Translation:Qty On Hand %>'></
asp:Label
>
</
td
>
<
td
style
=
"width: 80px;text-align:right"
>
<
asp:Label
ID
=
"lblQtyCommited"
runat
=
"server"
Text='<%$ Translation:Qty Committed %>'></
asp:Label
>
</
td
>
<
td
style
=
"width: 80px;text-align:right"
>
<
asp:Label
ID
=
"lblQtyAvailable"
runat
=
"server"
Text='<%$ Translation:Qty Available %>'></
asp:Label
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
table
style
=
"width:650px;text-align:left;"
class
=
"comboTable"
cellspacing
=
"0"
cellpadding
=
"0"
>
<
tr
>
<
td
style
=
"width: 100px;"
>
<
div
class
=
"comboItem"
>
<%#DataBinder.Eval(Container, "Text")%>
</
div
>
</
td
>
<
td
style
=
"width: 250px;text-align:left"
>
<
div
class
=
"comboItem"
>
<%#DataBinder.Eval(Container, "Attributes(""ItemName"")")%>
</
div
>
</
td
>
<
td
style
=
"width: 80px;text-align:left"
>
<
div
class
=
"comboItem"
>
<%#DataBinder.Eval(Container, "Attributes(""UOMID"")")%>
</
div
>
</
td
>
<
td
style
=
"width: 60px;text-align:right"
>
<
div
class
=
"comboItem"
>
<%#DataBinder.Eval(Container, "Attributes(""QtyOnHand"")")%>
</
div
>
</
td
>
<
td
style
=
"width: 80px;text-align:right"
>
<
div
class
=
"comboItem"
>
<%#DataBinder.Eval(Container, "Attributes(""QtyCommited"")")%>
</
div
>
</
td
>
<
td
style
=
"width: 80px;text-align:right"
>
<
div
class
=
"comboItem"
>
<%#DataBinder.Eval(Container, "Attributes(""QtyAvailable"")")%>
</
div
>
</
td
>
</
tr
>
</
table
>
</
ItemTemplate
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
asp:TemplateField
>
<
asp:TemplateField
HeaderText="<%$ Translation:Item Description %>" SortExpression="Description" >
<
ItemTemplate
>
<
asp:Label
ID
=
"lblItemDesc"
runat
=
"server"
Text='<%# Eval("Description") %>' Width="100%"></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"lblItemDesc"
runat
=
"server"
Text='<%# Bind("Description") %>' Width="100%"></
asp:Label
>
</
EditItemTemplate
>
</
asp:TemplateField
>
</
asp:GridView
>
My business Logic will monitor dataTable.ColumnChanging event which triggered by gridView.UpdateRow(gridView.EditIndex, False)
to trace every new values inserted or updated to the underlying DataTable object, and put other business logic in between before updating to the SQL Server Database.
Come to the Telerik RadGrid, I have justed replaced to the following coding as,
<
telerik:RadGrid
ID
=
"RadGridDOHeader"
Width
=
"99.9%"
ShowStatusBar
=
"true"
DataMember
=
"SalesReturnDetail"
DataSourceID
=
"DBDataSource2"
AutoGenerateColumns
=
"False"
PageSize="<%# EnterpriseCommon.Configuration.ConfigSettings.PagesPerBlock %>"
AllowSorting="True" AllowPaging="True" runat="server" AllowAutomaticUpdates ="True" AllowAutomaticInserts = "true" AllowAutomaticDeletes = "true"
Skin ="Hay" ShowGroupPanel="True" GroupPanel-Text = "" >
<
MasterTableView
Width
=
"100%"
DataKeyNames
=
"CompanyID,DivisionID,DepartmentID,SalesReturnNumber,SalesReturnLineNumber,ItemID"
PagerStyle-AlwaysVisible
=
"true"
EditMode
=
"InPlace"
AllowMultiColumnSorting
=
"True"
CommandItemDisplay
=
"TopAndBottom"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"ImageButton"
/>
<
telerik:GridButtonColumn
ConfirmText
=
"Delete this product?"
ConfirmDialogType
=
"RadWindow"
ConfirmTitle
=
"Delete"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
ConfirmDialogHeight
=
"100px"
ConfirmDialogWidth
=
"220px"
/>
<%-- <
telerik:GridBoundColumn
AutoPostBackOnFilter
=
"true"
SortExpression
=
"ItemUPCCode"
HeaderText="<%$ Translation:Item ID %>" HeaderButtonType="TextButton" DataField="ItemUPCCode" HeaderStyle-Width = "80" AllowFiltering ="False" />
--%>
<
telerik:GridTemplateColumn
DataField
=
"ItemUPCCode"
HeaderText
=
"Item ID"
UniqueName
=
"ItemUPCCode"
>
<
EditItemTemplate
>
<
telerik:RadComboBox
Skin
=
"Hay"
ID
=
"RadItem"
runat
=
"server"
Text ='<%# Bind("ItemUPCCode") %>' Height ="180" Width="97%"
HighlightTemplatedItems = "true" Sort="Ascending"
OnItemsRequested= 'RadComboBox_AllItemRequested' EnableLoadOnDemand ="true" ShowToggleImage="false"
DropDownWidth ="450" ShowMoreResultsBox ="true" EnableVirtualScrolling ="true" AutoPostBack ="true" >
<
HeaderTemplate
>
<
div
>
<
table
border
=
"0"
style
=
"width: 400px;text-align:left"
cellspacing
=
"0"
cellpadding
=
"0"
>
<
tr
>
<
td
style
=
"width: 100px;text-align:left"
>
<
asp:Label
ID
=
"lblItemID2"
runat
=
"server"
Text='<%$ Translation:Item ID %>'></
asp:Label
>
</
td
>
<
td
style
=
"width: 250px;text-align:left"
>
<
asp:Label
ID
=
"lblItemName2"
runat
=
"server"
Text='<%$ Translation:Item Name %>'></
asp:Label
>
</
td
>
</
tr
>
</
table
>
</
div
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
table
style
=
"width:400px;text-align:left;"
class
=
"comboTable"
cellspacing
=
"0"
cellpadding
=
"0"
>
<
tr
>
<
td
style
=
"width: 100px;"
>
<
div
class
=
"comboItem"
>
<%#DataBinder.Eval(Container, "Text")%>
</
div
>
</
td
>
<
td
style
=
"width: 250px;text-align:left"
>
<
div
class
=
"comboItem"
>
<%#DataBinder.Eval(Container, "Attributes(""ItemName"")")%>
</
div
>
</
td
>
</
tr
>
</
table
>
</
ItemTemplate
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
AutoPostBackOnFilter
=
"true"
SortExpression
=
"Description"
HeaderText="<%$ Translation:Item Description %>" HeaderButtonType="TextButton" DataField="Description" HeaderStyle-Width = "120"/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
And, I am not sure the life cycle of the RadGrid 's Binding scheme, how or in what command when the data keyed in at RadGrid save it to the Bindded object DataTable? Any Suggest?
0

Elliott
Top achievements
Rank 2
answered on 19 Mar 2012, 04:38 PM
to put your logic on the server you might consider something like this
Protected
Sub
gvVendor_ItemCommand(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
gvVendor.ItemCommand
Dim
gdItem
As
GridDataItem =
Nothing
Dim
gefItem
As
GridEditFormItem =
Nothing
Select
Case
e.CommandName
Case
"PerformInsert"
gdItem =
DirectCast
(e.Item, GridDataItem)
InsertVendor(gdItem)
Case
"Edit"
gdItem =
DirectCast
(e.Item, GridDataItem)
Case
"Update"
gdItem =
DirectCast
(e.Item, GridDataItem)
UpdateVendor(gdItem)
Case
"Delete"
End
Select
End
Sub
the type of item created by the various commands depends on your EditMode
this grid was InPlace
I left the stubs for Edit and Delete although I am not actually doing anything with them
0

w
Top achievements
Rank 1
answered on 19 Mar 2012, 04:47 PM
Thanks.
Can I say that at point of "InsertVendor(gdItem)" or "UpdateVendor(gdItem)", the data actually at client side, has not yet bind it to the underlying DataTable?
I need to extract the value from gdItem and save it to the DataTable, am I right to say that?
Can I say that at point of "InsertVendor(gdItem)" or "UpdateVendor(gdItem)", the data actually at client side, has not yet bind it to the underlying DataTable?
I need to extract the value from gdItem and save it to the DataTable, am I right to say that?
0

Elliott
Top achievements
Rank 2
answered on 19 Mar 2012, 04:57 PM
I only know what works for me
the event args object has a property of Item which contains information about the row in the grid being added, updated or deleted
somewhere else in my program is an event handler for NeedDataSource event of the grid
the update is invoked and performed (or not, perhaps) updating the database
in any event, the row goes out of edit mode and the grid (along with the DataTable) is updated from the database automatically
let Telerik decide when it needs to update the grid
the event args object has a property of Item which contains information about the row in the grid being added, updated or deleted
somewhere else in my program is an event handler for NeedDataSource event of the grid
the update is invoked and performed (or not, perhaps) updating the database
in any event, the row goes out of edit mode and the grid (along with the DataTable) is updated from the database automatically
let Telerik decide when it needs to update the grid
0

w
Top achievements
Rank 1
answered on 19 Mar 2012, 05:31 PM
I have plenty of the logic tight with DataTable datarow changing event, DataTable is actually act as a middle tier between client and database in my case, and GridView is just act as Front Data View, in order to make the migration succeed, I have to find out a way to update RadGrid to DataTable, thus the DataTable Column Changing event can be triggered and my whole structure can be continued.
0

Elliott
Top achievements
Rank 2
answered on 19 Mar 2012, 05:36 PM
you might consider triggerting your updates off the selected index changed event of the RadComboBox in the EditItemTemplate