As my grid is following http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/DataEditing/TemplateFormUpdate/DefaultVB.aspx to do, and I try to insert the FileUpload into FormTemplate, when I click insert, that's a problem on it
And the other thing, there's two radcombobox and two sqldatasources inside the FormTemplate, there also have a problem when I run
And the second combobox, it will check what client selected in combobox1, and bind this combobox.
| Protected Sub RadGrid1_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand |
| Dim Id As String = "1" 'I am not sure how to get the primary key when insert |
| Dim PhotoFile As FileUpload = CType(RadGrid1.FindControl("PhotoFileUpload"), FileUpload)' I think the findcontrol has a problem, but not sure how to modify |
| InsertedShoperPhoto(Id, PhotoFile) |
| End Sub |
| Public Sub InsertedShoperPhoto(ByVal Id As String, ByVal PhotoFile As FileUpload) |
| If (PhotoFile Is Nothing) Or (Not PhotoFile.HasFile) Then Return |
| Dim fileLen As Integer |
| fileLen = PhotoFile.PostedFile.ContentLength |
| Dim Input(fileLen) As Byte |
| Input = PhotoFile.FileBytes |
| Using cn As New SqlConnection(ConfigurationManager.ConnectionStrings("PLAZAConnectionString").ConnectionString) |
| Using cmd As New SqlCommand("UPDATE ShoperDetail SET Picture = @Photo WHERE spID = @Id", cn) |
| cmd.Parameters.Add("@Id", Data.SqlDbType.NVarChar, 10).Value = Id |
| cmd.Parameters.Add("@Photo", Data.SqlDbType.Image).Value = Input |
| cn.Open() |
| cmd.ExecuteNonQuery() |
| End Using |
| End Using |
| End Sub |
And the other thing, there's two radcombobox and two sqldatasources inside the FormTemplate, there also have a problem when I run
| <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource3" |
| DataTextField="STname" DataValueField="STname" RadComboBoxImagePosition="Right" |
| Skin="WebBlue" SelectedValue='<%# Bind("ShopType", "{0}") %>'> |
| <CollapseAnimation Duration="200" Type="OutQuint" /> |
| <ExpandAnimation Type="OutQuart" /> |
| </telerik:RadComboBox> |
| <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:PLAZAConnectionString %>" SelectCommand="SELECT DISTINCT [STname] FROM [ShopType]"> |
| </asp:SqlDataSource> |
And the second combobox, it will check what client selected in combobox1, and bind this combobox.
| <telerik:RadComboBox ID="RadComboBox2" runat="server" DataSourceID="SqlDataSource4" |
| DataTextField="STCategory" DataValueField="STCategory" RadComboBoxImagePosition="Right" |
| Skin="WebBlue" SelectedValue='<%# Bind("ShopCat", "{0}") %>'> |
| <CollapseAnimation Duration="200" Type="OutQuint" /> |
| <ExpandAnimation Type="OutQuart" /> |
| </telerik:RadComboBox> |
| <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:PLAZAConnectionString %>" SelectCommand="SELECT [STCategory] FROM [ShopType] WHERE ([STname] = @STname)"> |
| <SelectParameters> |
| <asp:ControlParameter ControlID="RadComboBox2" DefaultValue="Shopping" Name="STname" |
| PropertyName="SelectedValue" Type="String" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |
