Click here to Skip to main content
12,448,720 members (53,150 online)
Rate this:
Please Sign up or sign in to vote.
See more: C#
<asp:GridView ID="gvBillets" runat="server"  AutoGenerateColumns="false" OnRowDataBound="gvBillets_RowDataBound"  OnRowCommand="gvBillets_RowCommand"
                 DataKeyNames="BIN"  >
                        <asp:TemplateField HeaderText="Pri" ItemStyle-Width="20px" >
                               <asp:TextBox ID="tbPref" runat="server"  Width="20px" style="text-align:center" Text='<%# Eval("Preference") %>'   OnTextChanged="tbPref_TextChanged" AutoPostBack='true' ></asp:TextBox>
Posted 22-Feb-13 14:24pm
Tadit Dash 23-Feb-13 3:27am
Your codes are not posted correctly.
Please Improve.
Member 9782903 23-Feb-13 12:06pm
I have resubmitted code. OnTextChanged Event does not fire. Have a break point but it is never reached.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Here is repost of code.  tbPref_textchangedevent does not fire....
 <asp:gridview id="gvBillets" runat="server" autogeneratecolumns="false" onrowdatabound="gvBillets_RowDataBound" onrowcommand="gvBillets_RowCommand" xmlns:asp="#unknown">
                 DataKeyNames="BIN"  >
                        <asp:templatefield headertext="Pri" itemstyle-width="20px">
                               <asp:textbox id="tbPref" runat="server" width="20px" style="text-align:center" text="<%# Eval("Preference") %>" ontextchanged="tbPref_TextChanged" autopostback="true"></asp:textbox>
                                <itemstyle horizontalalign="Center"></itemstyle>
                        <asp:templatefield itemstyle-width="40%" headertext="Details">
                                <a id="A3" onclick="javascript:OpenBilletDetailsDialog('<%# Eval(" bin=") %>'); return false;">
                                    href=#><%# Eval("billet_name") %></a>
                        <asp:boundfield itemstyle-width="40%" headertext="Unit Name" readonly="true" datafield="unit_name" />
                        <asp:boundfield itemstyle-width="5%" headertext="RBSC" readonly="true" datafield="rbsc" />
                        <asp:boundfield itemstyle-width="5%" headertext="Desig" readonly="true" datafield="desig" />
                        <asp:boundfield itemstyle-width="5%" headertext="Rank" readonly="true" datafield="rank_desc" />
                        <asp:buttonfield buttontype="Link" commandname="Remove" itemstyle-horizontalalign="Center" itemstyle-cssclass="linkoff" headertext="Remove" text="X" />
                        <asp:boundfield datafield="BIN" visible="false" readonly="true" />
Here is code behind which does not fire.
   protected void tbPref_TextChanged(object sender, EventArgs e)
            GridViewRow row = ((GridViewRow)((TextBox)sender).NamingContainer);
            TextBox Pri = (TextBox)row.FindControl("tbPref");
            //code to go here when pri is changed
ProgramFOX 23-Feb-13 12:07pm
You can improve your question using the "Improve question" button.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Issue was with the page load event. Added if(!Page.IsPostBack) for page load event which allowed Text Changed event to fire.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

hi !!!!! Check this link

TextBox Change Event Inside GridView[^]

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100