Hi ....
Evaluation is progressing ...
TestProject works like this (short working code below)
I select a TableName from dropdown and create gridcolumns etc dynamicly.
Questions
I need to know how to get values from UpdateForm when I press "Update" and how can I raise an event when I delete a row?
I also want to know if this is the right way/approach to do what I am trying to do!
Doing it lijke this also gives me another problem. Filter is working but the filter expression has dissappeared from filter-textbox ... anyone know how to fix this?
Check the following working code ....
Form code
Code behind
Evaluation is progressing ...
TestProject works like this (short working code below)
I select a TableName from dropdown and create gridcolumns etc dynamicly.
Questions
I need to know how to get values from UpdateForm when I press "Update" and how can I raise an event when I delete a row?
I also want to know if this is the right way/approach to do what I am trying to do!
Doing it lijke this also gives me another problem. Filter is working but the filter expression has dissappeared from filter-textbox ... anyone know how to fix this?
Check the following working code ....
Form code
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="edit_new3.aspx.vb" Inherits="edit" %>
<%@ Register Src="Controls/RecordEditForm.ascx" TagName="RecordEditForm" TagPrefix="uc1" %>
<!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
></
title
>
</
head
>
<
body
class
=
"RecordEditForm"
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"TableComboBox"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"TableGrid"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"TableGrid"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"TableGrid"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
div
>
<
telerik:RadComboBox
ID
=
"TableComboBox"
runat
=
"server"
Skin
=
"Office2007"
AutoPostBack
=
"True"
>
<
Items
>
<
telerik:RadComboBoxItem
runat
=
"server"
Enabled
=
"False"
Font-Italic
=
"True"
Selected
=
"True"
Text
=
"Choose table"
Value
=
"Choose table ..."
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"Employees"
Value
=
"Employees"
/>
<
telerik:RadComboBoxItem
runat
=
"server"
Text
=
"Companies"
Value
=
"Companies"
/>
</
Items
>
</
telerik:RadComboBox
>
</
div
>
<
telerik:RadGrid
ID
=
"TableGrid"
runat
=
"server"
AllowSorting
=
"True"
Skin
=
"Office2007"
AllowFilteringByColumn
=
"True"
AutoGenerateColumns
=
"False"
>
<
ClientSettings
EnableRowHoverStyle
=
"True"
EnableAlternatingItems
=
"False"
/>
</
telerik:RadGrid
>
</
form
>
</
body
>
</
html
>
Code behind
Partial
Class
edit
Inherits
System.Web.UI.Page
Protected
Sub
TableGrid_ItemCommand(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
TableGrid.ItemCommand
Select
Case
e.CommandName
Case
"Updated"
'How to update my datatable in session
End
Select
End
Sub
Protected
Sub
TableGrid_NeedDataSource(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
TableGrid.NeedDataSourc
If
TableComboBox.SelectedIndex > 0
Then
'Clear columns
TableGrid.Columns.Clear()
'Declares
Dim
TempTable
As
New
Data.DataTable
'Build fixed columns for delete and edit row
Dim
EditColumn
As
New
Telerik.Web.UI.GridEditCommandColumn
TableGrid.MasterTableView.Columns.Add(EditColumn)
EditColumn.ButtonType = Telerik.Web.UI.GridButtonColumnType.ImageButton
Dim
DeleteColumn
As
New
Telerik.Web.UI.GridClientDeleteColumn
TableGrid.MasterTableView.Columns.Add(DeleteColumn)
DeleteColumn.ButtonType = Telerik.Web.UI.GridButtonColumnType.ImageButton
DeleteColumn.ConfirmText =
"Are you sure you want to delete the row?"
'Get Table .... create if it doesn-t exist
If
Session(TableComboBox.SelectedValue)
Is
Nothing
Then
CreateDataSource()
TempTable = Session(TableComboBox.SelectedValue)
'Loop through Fields and create Columns and SQL field select
For
Each
Column
As
Data.DataColumn
In
TempTable.Columns
Dim
BoundColumn
As
New
Telerik.Web.UI.GridBoundColumn
TableGrid.MasterTableView.Columns.Add(BoundColumn)
BoundColumn.DataField = Column.ColumnName
BoundColumn.HeaderText = Column.ColumnName
Next
'Set datasource
TableGrid.DataSource = TempTable
End
If
End
Sub
Protected
Sub
TableComboBox_SelectedIndexChanged(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
Handles
TableComboBox.SelectedIndexChanged
TableGrid.Rebind()
End
Sub
Sub
CreateDataSource()
'Create Table
Dim
EmployeeTable =
New
Data.DataTable
With
EmployeeTable
.TableName =
"Employees"
.Columns.Add(
"ID"
)
.Columns.Add(
"Name"
)
.Columns.Add(
"Phone"
)
.Rows.Add({1,
"John"
,
"444-667788"
})
.Rows.Add({2,
"Patric"
,
"555-556677"
})
End
With
Session(
"Employees"
) = EmployeeTable
Dim
CompanyTable
As
New
Data.DataTable
With
CompanyTable
.TableName =
"Companies"
.Columns.Add(
"ID"
)
.Columns.Add(
"Company"
)
.Columns.Add(
"Phone"
)
.Rows.Add({1,
"Microsoft"
,
"444-667788"
})
.Rows.Add({2,
"Google"
,
"555-556677"
})
End
With
Session(
"Companies"
) = CompanyTable
End
Sub
End
Class