By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,273 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,273 IT Pros & Developers. It's quick & easy.

Gridview Item Template Enter on Textbox to update

KalariaNitya
P: 34
Hello,
could anybody help me?
i have gridview, inside gridview i have one Update button & textbox
update button update the quantity entered in textbox.
i want to update the quantity on textbox on ENTER event.

i had done below code:

page_load()

Dim dgitem1 As GridViewRow
Dim txtquantity As TextBox
Dim btnupdateqty As New Button

For Each dgitem1 In GridView1.Rows
txtquantity = dgitem1.FindControl("TextBox2")
btnupdateqty = dgitem1.FindControl("btnmodify")
txtquantity.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnupdateqty.UniqueID + "').click();return false;}} else {return true}; ")
Next




inline code:--

<asp:GridView ID="GridView1" runat="server" Width="100%" RowStyle-CssClass="border_b"
GridLines="None" CellPadding="0" ShowHeader="False" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table cellspacing="1" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td align="center" width="100">
<a href='<%#FormatURL1(DataBinder.Eval(Container.Data Item,"prod_id"))%>' onclick="window.open(this.href,'','scrollbars=no, menubar=no, toolbar=no, resizable=yes, status=no, width=800, height=600'); return false;" target="_blank">
<asp:Image ID="Image1" runat="server" CssClass="border_img" ImageUrl='<%# FormatURL(DataBinder.Eval(Container.DataItem,"prod _id")) %>'
BorderStyle="Solid" BorderWidth="1px"></asp:Image></a></td>
<td valign="top">
<table id="Table1" cellspacing="0" cellpadding="3" width="100%" border="0">
<tbody>
<tr>
<td style="text-align: left; height: 30px;" class="paging" colspan="2" height="12">
&nbsp;&nbsp;&nbsp;<asp:Label ID="Label33" runat="server" CssClass="normaltext" Text="Product Name : "
Font-Bold="True"></asp:Label><asp:Label ID="lblinprodname" runat="server" CssClass="normaltext"
Text='<%# DataBinder.Eval(Container.Dataitem,"prod_name") %>' Font-Bold="True"></asp:Label><b
class="text_11_black_bold"></b></td>
</tr>
<tr>
<td style="width: 60%;" class="text_11_black_bold" align="left" height="12">
<table width="100%">
<tbody>
<tr>
<td style="width: 40%;" align="right"> Category:</td>
<td align="left" style="width: 60%">
<asp:Label ID="lblincategory" runat="server" Text='<%# DataBinder.Eval(Container.Dataitem,"cat_name") %>'
Font-Bold="False"></asp:Label></td>
</tr>
</tbody>
</table>
</td>
<td style="width: 20%;" class="text_11_black_bold" align="left">
<table width="100%">
<tbody>
<tr>
<td style="width: 50%" align="right">
Size:</td>
<td align="left" style="width: 50%">
<asp:Label ID="lblinsize" runat="server" Text='<%# DataBinder.Eval(Container.Dataitem,"size") %>'
Font-Bold="False"></asp:Label></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="text_11_black_bold" align="left" style="width: 60%">
<table width="100%">
<tbody>
<tr>
<td style="width: 40%;" align="right">
&nbsp;Sub Cat:</td>
<td align="left" style="width: 60%">
<asp:Label ID="lblinsubcategory" runat="server" Text='<%# DataBinder.Eval(Container.Dataitem,"scat_name") %>'
Font-Bold="False"></asp:Label></td>
</tr>
</tbody>
</table>
</td>
<td class="text_11_black_bold" align="left" style="width: 20%">
<table width="100%">
<tbody>
<tr>
<td style="width: 50%" align="right">
Weight:</td>
<td align="left" style="width: 50%">
<asp:Label ID="lblwgt2" runat="server" Text='<%# DataBinder.Eval(Container.Dataitem,"weight") %>'
Font-Bold="False"></asp:Label></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<asp:Label ID="Label4" runat="server" Visible="False" CssClass="text_11_black" Text='<%#DataBinder.Eval(Container.Dataitem,"prod_ id")%>'>

</asp:Label>
<asp:Label ID="lblincatid" runat="server" Visible="False" CssClass="text_11_black"
Text='<%# DataBinder.Eval(Container.Dataitem,"cat_id") %>'></asp:Label>
<asp:Label ID="lblinscatid" runat="server" Visible="False" CssClass="text_11_black"
Text='<%# DataBinder.Eval(Container.Dataitem,"scat_id") %>'></asp:Label>
<asp:Label ID="lblinprodid" runat="server" Visible="False" CssClass="text_11_black"
Text='<%#DataBinder.Eval(Container.Dataitem,"prod_ id")%>'></asp:Label>
<asp:Label ID="Label7" runat="server" Visible="False" CssClass="normaltext" Font-Bold="False"></asp:Label></td>
<td valign="top" style="width: 20%">
<table id="Table6" cellspacing="0" cellpadding="3" width="100%" align="center" border="0">
<tbody>
<tr>
<td class="paging" align="center" style="height: 30px" colspan="2">
<strong>Rate</strong>:<asp:Label ID="Label6" runat="server" CssClass="normaltext" Text='<%# DataBinder.Eval(Container.Dataitem,"rate") %>'></asp:Label>
<asp:Label ID="c1" runat="server" CssClass="normaltext" Text="<%# get_currency() %>"
Font-Bold="False"></asp:Label></td>
</tr>
<tr>
<td class="text_11_black_bold" align="right">
Qty:</td>
<td style="width: 100px" align="left">
<asp:TextBox onblur="Numeric_validation(this);" ID="TextBox2" runat="server" Width="40px"
CssClass="text_11_black" Text='<%# DataBinder.Eval(Container.DataItem,"qty") %>'
MaxLength="3"></asp:TextBox></td>
</tr>
<tr>
<td class="text_11_black_bold" align="right">
Total:</td>
<td style="width: 100px" align="left">
<asp:Label ID="Label71" runat="server" CssClass="normaltext" Text='<%# DataBinder.Eval(Container.Dataitem,"total") %>'
Font-Bold="False"></asp:Label>
<asp:Label ID="c2" runat="server" CssClass="normaltext" Text="<%# get_currency() %>"
Font-Bold="False"></asp:Label></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="right" colspan="3" height="35">
<table id="Table7" width="100%">
<tbody>
<tr>
<td style="height: 23px; width: 20%;" width="92" align="center">
<asp:LinkButton ID="lnkRemove" runat="server" CssClass="text_9_maroon_link" Text="Remove Item"
CommandArgument='<%# eval ("Prod_id") & "<||>" & eval("Prod_name") & "<||>" & String.Format(Ctype(Container,GridViewRow).RowInde x)%>'
CommandName="del"></asp:LinkButton></td>
<td style="height: 23px; width: 60%;" colspan="2">
&nbsp;&nbsp;
</td>
<td style="height: 23px; width: 20%;" align="center" width="88">
<asp:Button ID="btnmodify" OnClick="test1" runat="server" CssClass="btn_main" Text="Update">
</asp:Button></td>
</tr>
<tr>
<td colspan="4" style="height: 20px">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle CssClass="border_b"></RowStyle>
</asp:GridView>




public function test1()
''Here code to update quantity
end function

could anybody help me?

what i have to do?

any help will be appriciated..



i want to call test1 function, when i press enter on textbox
May 15 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.