-1

How to add Textbox in gridview and how to access to it and perform some calculations like Serno,Name,ServAmnt,Qty,Disc,netamt

netamt=servamnt*qty*discount
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
Rizwan
  • 9
  • 2
  • 6

1 Answers1

1

Take a look at the GridView Examples for ASP.NET 2.0: Working with TemplateFields MSDN tutorial as a strating point:

Specify TemplateField.ItemTemplate;

Put the asp:TextBox control into template;

Bind the required TextBox’s property via the binding expression with the required field from the underlying datasource:

<asp:TemplateField>
    <ItemTemplate>
        <asp:TextBox ID="txtUnitPrice" runat="server" Text='<%#Eval("UnitPrice")%>'>
        </asp:TextBox>
    </ItemTemplate>
</asp:TemplateField>
Mikhail
  • 9,186
  • 4
  • 33
  • 49
  • I had added text boxes in the gridview,now want to show data in the textbox how can it be possible,please help me.!!!!!!!!!! – Rizwan Oct 01 '11 at 13:39
  • I am using this text field ---Text='<%# DataBinder.Eval(Container, "DataItem.ServiceCode") %>' runat="server" Width="55px"> it is giving error ---DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ServiceCode'. I changed this with Eval and Bind also it is giving the same error – Rizwan Oct 02 '11 at 15:17
  • it is necessary to use the “Eval” method as follows: Text='<%# DataBinder.Eval(Container.DataItem, “ServiceCode") %>' – Mikhail Oct 02 '11 at 20:04
  • How to write textchanged event in item template in a gridview – Rizwan Oct 03 '11 at 07:12
  • How to display data in textbox that are created by an item template in a gridview the values are Serno,Name,ServAmnt,Qty,Disc,netamt,after display the data it should perform calculation like: netamt=(servamnt*qty)*discount help me to solve this problem..!!!!!!!!!!!! – Rizwan Oct 04 '11 at 07:02
  • calculation should be client-side or server-side? – Mikhail Oct 04 '11 at 14:25
  • Client side calculation,send me the code for gridview calculation – Rizwan Oct 15 '11 at 08:10
  • i have no idea how to do calculation,either to use javascript or through programming suggest me the steps......!!!!!!!!! – Rizwan Oct 15 '11 at 14:38