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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Madhu KPosted Nov 12, 2010, 4:44 AM
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
CrishPosted Nov 12, 2010, 7:14 AM
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);
}
CrishPosted Nov 12, 2010, 4:38 AM
i WANT TO use textbox change event in datagrid. how can i use it ?
Suthish NairPosted Nov 12, 2010, 3:15 AM
Also, explain what change event going to do?