Click here to Skip to main content
Rate this: bad
good
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"  >
                    <Columns>
                        <asp:TemplateField HeaderText="Pri" ItemStyle-Width="20px" >
                            <ItemTemplate>
                               <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>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="40%" HeaderText="Details">
                            <ItemTemplate>
                                <a id="A3"  önclick="javascript:OpenBilletDetailsDialog('<%# Eval("bin") %>'); return false;"
                                    href=#>
Posted 22-Feb-13 14:24pm
Comments
Tadit Dash at 23-Feb-13 3:27am
   
Your codes are not posted correctly.
Please Improve.
Member 9782903 at 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
good
Please Sign up or sign in to vote.

Solution 1

hi !!!!! Check this link
 
TextBox Change Event Inside GridView[^]
  Permalink  
v2
Rate this: bad
good
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"  >
                    <columns>
                        <asp:templatefield headertext="Pri" itemstyle-width="20px">
                            <itemtemplate>
                               <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>
                            </itemtemplate>
                        </asp:templatefield>
                        <asp:templatefield itemstyle-width="40%" headertext="Details">
                            <itemtemplate>
                                <a id="A3" onclick="javascript:OpenBilletDetailsDialog('<%# Eval(" bin=") %>'); return false;">
                                    href=#><%# Eval("billet_name") %></a>
                            </itemtemplate>
                        </asp:templatefield>
                        <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" />
                       
                       
                    </columns>
                </asp:gridview>
 
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
 

 
  Permalink  
Comments
ProgramFOX at 23-Feb-13 12:07pm
   
You can improve your question using the "Improve question" button.
Rate this: bad
good
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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 398
1 CPallini 333
2 George Jonsson 270
3 OriginalGriff 159
4 Prasad Khandekar 135
0 OriginalGriff 4,613
1 CPallini 3,340
2 Sergey Alexandrovich Kryukov 2,771
3 George Jonsson 2,254
4 Gihan Liyanage 2,020


Advertise | Privacy | Mobile
Web01 | 2.8.140905.1 | Last Updated 23 Feb 2013
Copyright © CodeProject, 1999-2014
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