Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3692470
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:15:58+00:00 2026-05-19T04:15:58+00:00

I have write this code to create a gridview with 3 columns DataTable dt

  • 0

I have write this code to create a gridview with 3 columns

DataTable dt = new DataTable();
dt = new DataTable();
dt.Columns.Add("ID", typeof(int)).AutoIncrement = true;
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Price(Grouch)/Hectares", typeof(float));
DataColumn[] keys = new DataColumn[2];
keys[0] = dt.Columns["ID"];
dt.PrimaryKey = keys;
dt.Rows.Add("1", "Seaside Location", 1.5);

Session[key] = dt;
return dt;

I would like to add in this code a textbox with the quantity.

When i give the quantity i want in another textbox to have the total.

for example 2*1.5=3

How can i do that?

My huge problem is that i dont know how to take the values of the 3rd column.The value 1.5 in this example.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:15:58+00:00Added an answer on May 19, 2026 at 4:15 am

    If i’ve understood you correctly, you want a TextBox in the price-column and a textbox for the total price. You could use a TemplateColumn to show the price in a textbox and the footer to show the totalprice.

    ASPX:

      <asp:GridView ID="GridView1" runat="server" ShowFooter="true" AutoGenerateColumns="false" >
            <Columns>
            <asp:BoundField HeaderText="ID" DataField="Name" />
            <asp:BoundField HeaderText="Name" DataField="Name" />
            <asp:TemplateField HeaderText="Price(Grouch)/Hectares">
                <ItemTemplate>
                    <asp:TextBox ID="TxtPrice" runat="server"></asp:TextBox>
                </ItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="TxtTotal" runat="server" Text="0"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
            </Columns>
        </asp:GridView>
    

    Sorry for VB.Net, i hope you see what i mean anyway, the importan part is in RowDataBound of the GridView:

       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                BindGrid()
            End If
        End Sub
    
        Private Sub BindGrid()
            Dim dt As New DataTable
            dt.Columns.Add("ID", GetType(Int32)).AutoIncrement = True
            dt.Columns.Add("Name", GetType(String))
            dt.Columns.Add("Price(Grouch)/Hectares", GetType(Single))
            dt.PrimaryKey = New DataColumn() {dt.Columns("ID")}
            Dim newRow As DataRow = dt.NewRow
            newRow("ID") = 1
            newRow("Name") = "Seaside Location"
            newRow("Price(Grouch)/Hectares") = 1.5
            dt.Rows.Add(newRow)
            newRow = dt.NewRow
            newRow("ID") = 2
            newRow("Name") = "City Location"
            newRow("Price(Grouch)/Hectares") = 7.9
            dt.Rows.Add(newRow)
            Me.GridView1.DataSource = dt
            Me.GridView1.DataBind()
        End Sub
    
        Private totalPrice As Single = 0
        Private Sub GridRowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
            If e.Row.RowType = DataControlRowType.DataRow Then
                Dim row As DataRow = DirectCast(e.Row.DataItem, DataRowView).Row
                Dim txtPrice As TextBox = DirectCast(e.Row.FindControl("TxtPrice"), TextBox)
                Dim price As Single = DirectCast(row("Price(Grouch)/Hectares"), Single)
                txtPrice.Text = price.ToString
                totalPrice = totalPrice + price
            ElseIf e.Row.RowType = DataControlRowType.Footer Then
                Dim txtTotal As TextBox = DirectCast(e.Row.FindControl("TxtTotal"), TextBox)
                txtTotal.Text = totalPrice.ToString
            End If
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have write this block of code in jquery to create three element after
I'm sure I'm going to have to write supporting javascript code to do this.
I am new to both sockets and threads. I have this code: listen(socket_fd, 20);
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to
Hi guys I wrote this code and i have two errors. Invalid rank specifier:
I have just upgraded my server 2003 to serrver 2008. As I write this,
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),
I have three tables. This query will write down the right answer (x-lines for
I have been told and I'm not sure I believe this: Removing white space
I have this Array i wrote a function MostFreq that takes an array of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.