Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I want to add items in my gridview.When i click submit button it works fine.but whenever i press enter in the textbox it calls a button event btnimgnew_Click automatically which i dont want.Below is my C# code.Any help will be appreciated.

C#
protected void btnimgnew_Click(object sender, ImageClickEventArgs e)
    {

        connfordata.Open();
        SqlCommand cmdfrexesp = new SqlCommand("sp_SRXO_InsDocTemplate", connfordata);
        cmdfrexesp.Parameters.AddWithValue("@W113_CompanyID", 5);
        cmdfrexesp.Parameters.AddWithValue("@W113_WebstoreID", 23);
        cmdfrexesp.Parameters.Add("@W113_XMLID", SqlDbType.Int).Direction = ParameterDirection.Output;
        cmdfrexesp.CommandType = CommandType.StoredProcedure;
        cmdfrexesp.ExecuteNonQuery();
        int yourResult = Convert.ToInt32(cmdfrexesp.Parameters["@W113_XMLID"].Value);
        connfordata.Close();
        txtCurrentOrder.Text = yourResult.ToString();
    }

    protected void txtOrderLineNo_TextChanged(object sender, EventArgs e)
    {
        
        Addtogrid(); 
        
    }
public void Addtogrid() 
{
//some code here
}
Posted

Go into the properties for your button and set UseSubmitBehaviour to false.
 
Share this answer
 
Comments
Amit Karyekar 2-Oct-13 22:06pm    
i guess Image button doesnt have usesubmitbehaviour property.
_Damian S_ 2-Oct-13 22:26pm    
That's a bit disappointing then!! Basically you are looking to change the "submit on enter" behaviour. You can use a bit of javascript to catch the enter key and ignore it if that will help...
Its good to catch the event when Enter key is pressed and proceed accordingly. See this link

How to disable submit behaviour of asp:ImageButton?[^]

Regards..
 
Share this answer
 

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