How to insert datatable into database using vb.net and asp.net ?

CheeFaiy 1 Reputation point
2022-07-28T06:10:09.307+00:00

I have this code for grid view

   <asp:GridView ID="grdNewClaim" CssClass="table table-bordered table-condensed"   
            GridLines="None" runat="server" AutoGenerateColumns="false"  
            ShowHeaderWhenEmpty="true" >  
    <Columns>  
        <asp:BoundField DataField="claim_type" HeaderText="Claim Type" />  
        <asp:BoundField DataField="purpose_desc" HeaderText="Purpos/Description" />  
        <asp:BoundField DataField="currency" HeaderText="Currency" />  
        <asp:BoundField DataField="amount" HeaderText="Amount" />  
        <asp:TemplateField HeaderText="Currency Rate">  
           <ItemTemplate>  
                <asp:TextBox ID="txtCRateZoo" runat="server"  
                    Text = '<%# Eval("txtChangeCurrRate") %>'>  
                </asp:TextBox>  
           </ItemTemplate>  
        </asp:TemplateField>  
        <asp:TemplateField HeaderText="Converted Rate">  
            <ItemTemplate>  
                <asp:TextBox ID="txtConvertedRate" runat="server"                          
                    Text = '<%# Eval("txtChangeCurrRate") %>' >  
  
                </asp:TextBox>  
            </ItemTemplate>  
        </asp:TemplateField>  
    </Columns>  
</asp:GridView>  

Everything works just fine until I want to insert the datatable into database. The value in the textboxes rows becomes 0.00000 instead of the actual values for example 23.56. The other values inserted correctly and just fine. This is the code to insert into database.

   Private Function AddClaim() As Integer  
        If grdNewClaim.Rows.Count > 0 Then  
            For i = 0 To grdNewClaim.Rows.Count - 1  
                Using insertDetail As New clshrReimbursementclaimdetaildal  
                    Dim obj As New clshrReimbursementclaimdetailsinfo  
                    With obj  
                        .parent_id = clsCommon.ToInt(lblHiddenID.Text)  
                        .claim_type = grdNewClaim.Rows(i).Cells(1).Text  
                        .purpose_desc = grdNewClaim.Rows(i).Cells(2).Text  
                        .currency = grdNewClaim.Rows(i).Cells(3).Text  
                        .amount = clsCommon.ToDbl(grdNewClaim.Rows(i).Cells(4).Text)  
                        .currency_rate = clsCommon.ToDbl(grdNewClaim.Rows(i).Cells(5).Text)  
                        .converted_rate = clsCommon.ToDbl(grdNewClaim.Rows(i).Cells(6).Text)  
                        .created_by = Membership.GetUser.ProviderUserKey  
                    End With  
                    Dim intResult As Integer = insertDetail.insertDetail(obj)  
                End Using  
            Next  
        End If  
        Return 1  
    End Function  
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,270 questions
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,578 questions
{count} votes