Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
i have a textbox named txtrateperUnit inside Gridview and i have used Itemtemplate on .Aspx page like below
XML
<ItemTemplate>
        <asp:TextBox ID="txtrateperUnit" runat="server" ontextchanged="txtrateperUnit_TextChanged" AutoPostBack="true"></asp:TextBox>



and on Code behind i have raised the event:
C#
protected void txtrateperUnit_TextChanged(object sender, EventArgs e)
        {
string a=a+10;
        }

but when i add some value in the textbox in runtime the event doesnt get raised...

what could be the Probs.

Pl reply

regards,
aamir
Posted

Firstly, I would suggest you use Javascript to perform any calculations, if you have values required for calculation instead of taking values to server. For Text_Changed event:
textbox-change-event-inside-gridview[^]
 
Share this answer
 
Hi ,
Check this
XML
<div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataSourceID="SqlDataSource1">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"
                        Text="<%# Bind('orderID') %>" ontextchanged="TextBox1_TextChanged"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:TextBox ID="TextBox2" runat="server" Text="<%# Bind('productID') %>"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
        SelectCommand="SELECT [orderID], [productID] FROM [ODetails]">
    </asp:SqlDataSource>
</div>


C#
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
    Response.Write("<script> alert('test')</script>");
}

Best Regards
M.Mitwalli
 
Share this answer
 
Comments
aamir07 4-Jul-12 3:50am    
Frnds,
i need this functionality in my web form.
pls suggest me about this topic.

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