Click here to Skip to main content
11,799,282 members (75,193 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET

I have an gridview with four controls inside "item template" like

Textbox1, Which was an Autocomplete Type using "Handler.ashx" and "JQuery". //Product name
Dropdownlist, with listitems //Product type(only 3 types)
Textbox2, //Number of Pages
Textbox3. //Number of copies

When user enter text inside that Textbox1, it will retrieve database values to fill the Autocomplete text.

Actually i use an CSS class to assign the User selected values to the Textbox.My Problem is now changing the value of the textbox1, textChanged event not fired.

Please help me out..

My textbox is below...

<asp:TextBox ID="txt_prodname" runat="server" CssClass="autocompleteTXT"
                     onblur="ValidatePname(this);" Width = "100px" AutoPostBack="True" ontextchanged="txt_prodname_TextChanged"></asp:TextBox>

protected void txt_prodname_TextChanged(object sender, EventArgs e)
       GridViewRow grdRow = ((System.Web.UI.WebControls.TextBox)sender).Parent.Parent as GridViewRow;
       TextBox txtprodname = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].Cells[1].FindControl("txt_prodname"));
       DropDownList txttype = (DropDownList)(Grid_billing.Rows[grdRow.RowIndex].Cells[2].FindControl("ddl_Prodtype"));
       TextBox txtpages = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].Cells[3].FindControl("txt_pages"));
       TextBox txtcopies = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].Cells[3].FindControl("txt_Copies"));
       TextBox txtFCamt = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].FindControl("txt_FCamt"));
       TextBox txtACamt = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].FindControl("txt_ACamt"));
       TextBox txtExtra = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].FindControl("txt_extra"));
       TextBox txtTotal = (TextBox)(Grid_billing.Rows[grdRow.RowIndex].FindControl("txt_total"));
       txttype.SelectedIndex = 0;txtpages.Text = "";
       txtcopies.Text = ""; txtACamt.Text = ""; txtFCamt.Text = "";
       txtExtra.Text = ""; txtTotal.Text = "";
       txt_assess_value.Text = ""; txt_netamt.Text = "";

Actually i know after Postback only the selected value will assign to the textbox. But even i gave "AUTOPOSTBACK" as TRUE. Its not postback.

Is there any other way to postback my page, while onblur of my textbox???
Because user may change textbox2, textbox3 and then textbox1. I have postback on textbox2 and textbox3 only working properly. So i need textbox1 postback to made textchanged event.

Even i didn't use UPDATE PANEL here Please help me out.
Posted 7-Aug-11 21:28pm
Edited 10-Aug-11 19:36pm
thatraja at 8-Aug-11 3:33am
Show the code for txt_prodname_TextChanged
jkarthick1989 at 8-Aug-11 3:45am
Please check my code above....
jkarthick1989 at 8-Aug-11 3:52am
Hope you dont need any Explanation. When user change the value of "txtprodname" i need to refresh the entire Row. Thats wat i need this Event.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You code looks like almost ok. Anyway I found this KB in web, try that & let me know. BTW are you using IE?

The TextChanged event of a TextBox control may not fire if the AutoComplete feature is enabled in Internet Explorer[^]
jkarthick1989 at 9-Aug-11 8:53am
yaa...I'm using IE8.
I refered your link already...before i made this post

Anyways thanks for your reply. But still i cant find solution :(
Now i just change this event code to the nearby Dropdownlist. Please Post me if you find any Solution
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Atlast found my solution,

This post may useful for future Developers,....

As i mentioned above in my Question, my page is not postback to assign the text values to the sever.

Let me clear myself once again,


Hence, i postback my page DYNAMICALLY through ONBLUR event of JAVASCRIPT


<asp:TextBox ID="txt_prodname" runat="server" Width="110px" onblur="dopost();"
                        CssClass="autocompleteTXT" AutoPostBack="True"

In my dopost(), i have added my script as below

<script type="JAVASCRIPT">
function dopost()
__doPostBack('__Page', 'MyCustomArgument');

__doPostBack was an inbuilt function of ASPX page. For more info, refer[^]
vipinvasu at 1-Aug-12 4:13am
Thank u so much..Your code works good..
jkarthick1989 at 2-Aug-12 1:07am
Welcome vipinvasu !!

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

  Print Answers RSS
0 OriginalGriff 473
1 CPallini 410
2 Richard MacCutchan 319
3 phil.o 244
4 Kornfeld Eliyahu Peter 205
0 OriginalGriff 2,475
1 Maciej Los 1,860
2 KrunalRohit 1,496
3 CPallini 1,465
4 Richard MacCutchan 1,149

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 11 Aug 2011
Copyright © CodeProject, 1999-2015
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