Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
on selecting dropdown list in gridview its rate has to be displayed in label of that row, in the same row quantity column is to make user to enter quantity in textbox. and the amount has to be displayed by calculating quantity* rate . and this gridview must be autogenerated.

What I have tried:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                ShowHeaderWhenEmpty="True" ShowFooter="True"
                Width="595px" onselectedindexchanged="GridView1_SelectedIndexChanged" 
                    <asp:TemplateField HeaderText="Sno" SortExpression="Sno">
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Sno") %>'>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Sno") %>'>
                            <asp:LinkButton ID="LinkButton1" runat="server">Insert
                    <asp:TemplateField HeaderText="Product" SortExpression="Product">
                            <asp:Label ID="Labelt" runat="server" Text='<%# Bind("Product") %>'>
                            <asp:DropDownList runat="server" DataSourceID="slsfConnectionString3" DataValueField="Prid"  DataTextField="Product" Id="ddp">
                    <asp:TemplateField HeaderText="Quantity" SortExpression="Quantity">
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("Quantity") %>'>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Quantity") %>'>
                    <asp:TemplateField HeaderText="Rate" SortExpression="Rate">
                            <asp:Label ID="Label5" runat="server" Text='<%# Bind("Rate") %>' >
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("Rate") %>'>

                    <asp:TemplateField HeaderText="Amount" SortExpression="Amount">

                            <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Amount") %>'>
                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("Amount") %>'>
                        <asp:Label ID="Label6" runat="server" Text='<%# Eval("Amount") %>'>
Updated 3-May-17 1:26am
ZurdoDev 3-May-17 7:19am    
Decide if you want to use JavaScript or C# to do it and then tells us where you are stuck.

1 solution

You can do that by server side and client side as well

There are many solutions available on google, You should check it.

For more info

How to do Calculations in GridView[^]

Calculate Running Total in ASP.Net GridView using jQuery[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900