Friday, September 19, 2008

on datagrid edit how to focus on textbox


protected void dgAnnouncement_ItemCommand(object source, DataGridCommandEventArgs e)
{

switch(e.CommandName)
{
case "Edit":
dg.EditItemIndex = e.Item.ItemIndex;
.
.
fillurDataGrid
.
.
TextBox txtSub1 = (TextBox) dg.Items[e.Item.ItemIndex].Cells[0].FindControl("txtSubject");

// "Control differ according to the control you used within the DataGrid Column Here me used TextBox"

// "Cells[0] --> "Position Of The Column In The DataGrid"

// "FindControl("txtSubject") --> Control Id Which Within the Particular Cell

txtSub1.Focus();
}
}

No comments: