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:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.