Hi All,
I am using textbox in datagrid. Now i want textbox change event in datagrid. Please provide me sample code for how to get event in codebehind.
thanks
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Madhu KRank #1,514 · 1.1K reputationPosted Nov 11, 2010, 11:44 PM EST
protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (!Page.IsPostBack)
{
if (e.Item.ItemType == ListItemType.Item)
{
TextBox ddl = e.Item.FindControl("TextBox1") as TextBox;
ddl.TextChanged += new EventHandler(TextBox1_TextChanged);
}
}
}
TextBox changed event
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
// Your code
}
Make sure your TextBox AutopostBack property to true
Suthish NairRank #92 · 22.8K reputationPosted Nov 11, 2010, 10:15 PM EST
Also, explain what change event going to do?
CrishRank #1,486 · 1.1K reputationPosted Nov 11, 2010, 11:38 PM EST
i WANT TO use textbox change event in datagrid. how can i use it ?
CrishRank #1,486 · 1.1K reputationPosted Nov 12, 2010, 2:14 AM EST
working perfect...
set AutoPostBack="true" OnTextChanged="txtProductQty_TextChanged" in Datagrid
protected void txtProductQty_TextChanged(object sender, EventArgs e)
{
TextBox txtbox = (TextBox)sender;
int qt = Convert.ToInt32(txtbox .Text.Trim());
TableCell tbCell = (TableCell)txtbox .Parent;
DataGridItem di = (DataGridItem)tbCell .Parent;
int ProductID = Convert.ToInt16(di.Cells[0].Text);
int catID = Convert.ToInt16(di.Cells[1].Text);
}