My code below doesn’t find the textbox:
protected void AddActivityTextBox_TextChanged(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
string ID = tb.UniqueID;
TextBox tb2 = (TextBox)GvAddActivityData.FindControl(ID);
}
This is a textbox from inside a GridView so I must use the UniqueID instead of the ID property as there is a textbox with the same ID for each row.
However FindControl() returns null.
You don’t need to find the TextBox, you have already found it with
tb. The TextBox invoked this function, and is therefore thesenderobject.Anything you would be able to do with
tb2you can already do withtb.Having said that, if you have the UniqueID of the control, you can find it using
Page.FindControl: