Forums

Update value on datagrid cell within an edit field.

Last post 6/12/2009 5:27 PM by Mark Cenal. 0 replies.
Sort Posts: Previous Next
  • Mark Cenal

    Update value on datagrid cell within an edit field.

    6/12/2009 5:27 PM
    • Not Ranked
    • Joined on 6/12/2009
    • Posts 1

    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:&nbsp;<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

    Filed under: ,
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.