Click here to Skip to main content
15,905,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

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...

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


C#
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
Updated 10-Aug-11 19:36pm
v6
Comments
thatraja 8-Aug-11 3:33am    
Show the code for txt_prodname_TextChanged
J.Karthick 8-Aug-11 3:45am    
Please check my code above....
J.Karthick 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.

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[^]
 
Share this answer
 
Comments
J.Karthick 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
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,

"CAUSING POSTBACK ONLY MAKES THE CONTROLS TO RETAIN THEIR VALUES"

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

like

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


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

C#
<script type="JAVASCRIPT">
function dopost()
{
__doPostBack('__Page', 'MyCustomArgument');
}
</script>



__doPostBack was an inbuilt function of ASPX page. For more info, refer

http://www.dotnetspider.com/resources/1521-How-call-Postback-from-Javascript.aspx[^]
 
Share this answer
 
Comments
vipinvasu 1-Aug-12 4:13am    
Hi,
Thank u so much..Your code works good..
J.Karthick 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900