Please help me on this since I am new. Thanks a lot.
I changed the text box to a dropdown as below:
from
<telerik:GridBoundColumn DataField="name" DefaultInsertValue=""
HeaderText="name" SortExpression="name" UniqueName="name">
</telerik:GridBoundColumn>
to
<telerik:GridDropDownColumn DatasourceID=sqldatasource2 ListValueField=name ListTextField=name
EnableEmptyListItem=true EmptyListItemText="choose an option" DataField="name"
datatype=System.String
HeaderText="name" SortExpression="name" UniqueName="name">
</telerik:GridDropDownColumn>
the statement below from insertCommand event handler failed since I don't know how to get the selected value from the dropdown
Dim CompanyName As String = TryCast(newItem("name").Controls(0), TextBox).Text
Please help me.
---------------------------------------------------------------------------------------------------------------------
[VB] InsertCommand event handler
'Get the GridEditableItem of the RadGrid
Dim
newItem
As GridEditableItem = TryCast(e.Item, GridEditableItem)
'Access the textbox from the edit form template and store the values in string variables.
Dim
CompanyName As String = TryCast(newItem("CompanyName").Controls(0), TextBox).Text
Dim
Phone As String = TryCast(newItem("Phone").Controls(0), TextBox).Text
Try
'Insert Query execution
SqlDataSource1.InsertCommand =
"INSERT INTO Shippers (CompanyName, Phone) Values ('" +
CompanyName +
"','" + Phone + "')"
SqlDataSource1.Insert()
Catch
ex As Exception
RadGrid1.Controls.Add(
New LiteralControl("Unable to insert Shipper. Reason: " +
ex.Message))
e.Canceled =
True
End Try
--------------------------------------------------------