Maybe I'm not doing this the best fashion, but I have a ASPxGridView displaying some data from a dataview in a MSSQL Database.
From there I click on the edit or new for a row and it opens up with a normal .net FileUpload field which calls code in my codebehind to handle the binary data upload into SQL.
The files aren't actually images but a custom format of data I need in binary files. From there I return the value of the index of my last insert and I need to put that data into
the final update command of the Edit Row of the ASPxGridView. Is there any way that I can get access to a cell in the current editing field?
My ASPX Code:
<dxwgv:GridViewDataTextColumn FieldName="LabelFileID" VisibleIndex="5">
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn VisibleIndex="6" Caption="LabelFileData">
<EditItemTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
<Triggers>
<asp:PostBackTrigger ControlID="UploadBtn" />
</Triggers>
<ContentTemplate><br />
<table><tr><td colspan="2"><asp:FileUpload ID="LabelFileData" runat="server" Width="270px" /></td></tr>
<tr><td>File Uploaded: <asp:Label ID="Label1" runat="server" BackColor="#FFFF80"></asp:Label></td>
<td align="right"><asp:Button ID="UploadBtn" runat="server"
Text="Upload" OnClick="UploadBtn_Click" /></td></tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</EditItemTemplate>
</dxwgv:GridViewDataTextColumn>
My VB.Net code:
Protected Sub UploadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If LabelFileData.HasFile Then
Label1.Text = LabelFileData.FileName
'Need to insert into the table to get the actual id for the data file that should be set to VALUE.
Dim Value As String = ""
DB = New DBConn() 'This creates my Database connection
Value = DB.Insert("INSERT INTO LABELFILE (LabelFileName) VALUES ('" & LabelFileData.FileName & "'); SELECT IDENT_CURRENT('LABELFILE')") 'This returns my ID of the binary file.
DB.InsertBinaryFile(LabelFileData.FileContent, Value) 'This inserts the binary data.
End If
'What I would like to do here is something like
' ASPxGridView.SelectedIndexRow("LabelFileID") = Value.ToString
End Sub