View Single Post
  #120 (permalink)  
Old 09-24-2007, 02:26 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up 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
Reply With Quote