Re: ASP.NET Data Controls hi,
You needn't put both a label and textboxn in edititemtemplate to achieve this. You are right you should add some additional code in PreRender event handler of the GridView. You just need to retrieve the value from TextBox and assign it to the Text of the cell, where the TextBox is located. The TextBox won't display any more.
Here is an example. I hope it can help.
protected void GridView1_PreRender(object sender, EventArgs e)
{
if (GridView1.EditIndex != -1&&role=="admin")
{
GridViewRow editRow = GridView1.Rows[GridView1.EditIndex];
//get the textbox
TextBox tb = (TextBox) editRow.FindControl("TextBox1");
// get the cell where the textbox is located
TableCell cell = (TableCell) tb.Parent;
cell.Text = tb.Text;
}
}
__________________ Venkat knowledge is Power |