Tuesday, January 11, 2011

in my radgrid i use template as EditFormType. When I open the edit form for a grid item I want to show or hide a texbos based on the value populated in it. It can be achieved this way:

Protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem item = (GridEditFormItem)e.Item;
TextBox TextBox1 = (TextBox)item.FindControl("TextBox1");
//OR/// TextBox txtbox = (TextBox)item["TextBox1"].Controls[0];
if (TextBox1.Text == "your value")
{
TextBox1.Visible = false;
}
}
}

No comments: