- Home
- Forum
- ASP.NET Web Forms (Classic)
- Set focus in edit mode
Set focus in edit mode
- Dec 30, 2010 05:01 PM UTC
- Jan 5, 2011 02:34 PM UTC
I have a GridGroupingControl with some text columns and Edit, Delete columns.
The FormEditMode is not set so it uses the default inline editing.
When I click the Edit link button on a row, I want to set the focus on the first text box that shows up.
How do I do that?
I tried the following but it didn't work
void UserGrid_RowDataBound(object sender, RowDataBoundEventArgs e)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor != null)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "FirstName")
{
if (e.Element.GetRowIndex() == SelectedRowIndex)
{
if (e.Row.Cells[i].Controls.Count > 0)
{
Control c = e.Row.Cells[i].Controls[0];
if (c != null)
{
c.Focus();
}
}
}
}
}
}
}
The FormEditMode is not set so it uses the default inline editing.
When I click the Edit link button on a row, I want to set the focus on the first text box that shows up.
How do I do that?
I tried the following but it didn't work
void UserGrid_RowDataBound(object sender, RowDataBoundEventArgs e)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor != null)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "FirstName")
{
if (e.Element.GetRowIndex() == SelectedRowIndex)
{
if (e.Row.Cells[i].Controls.Count > 0)
{
Control c = e.Row.Cells[i].Controls[0];
if (c != null)
{
c.Focus();
}
}
}
}
}
}
}
SIGN IN To post a reply.
3 Replies
SN
Sridhar N
Syncfusion Team
December 31, 2010 07:17 AM UTC
Hi Sorin,
Thanks for using Syncfusion Products.
Your requirement of setting focus to textbox on clicking EditLinkButtton can be achieved by setting Focus to corresponding cell.
Please refer the below code snippet.
[Codebehind - C#]
For your convenience, we have created a sample and the same can be downloaded from the following link.
Sample1-1661924861.zip
Could you please try the above sample and get back to us with more information that whether your using EditItemTemplate or not? The information provided would be of great help in resolving the issue.
Please let us know your concerns.
Regards,
Sridhar.N
Thanks for using Syncfusion Products.
Your requirement of setting focus to textbox on clicking EditLinkButtton can be achieved by setting Focus to corresponding cell.
Please refer the below code snippet.
[Codebehind - C#]
void GridGroupingControl1_RowDataBound(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.RowDataBoundEventArgs e)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor != null)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "ID")
{
if (e.Element.GetRowIndex() == selectedrowindex )
{
e.Row.Cells[i].Focus();
}
}
}
}
}
For your convenience, we have created a sample and the same can be downloaded from the following link.
Sample1-1661924861.zip
Could you please try the above sample and get back to us with more information that whether your using EditItemTemplate or not? The information provided would be of great help in resolving the issue.
Please let us know your concerns.
Regards,
Sridhar.N
SR
Sorin Rojea
January 4, 2011 02:09 PM UTC
It worked, thank you!
SN
Sridhar N
Syncfusion Team
January 5, 2011 02:34 PM UTC
Hi Sorin,
We are happy to hear that your issue is solved.Thanks for your reply.
Regards,
Sridhar.N
We are happy to hear that your issue is solved.Thanks for your reply.
Regards,
Sridhar.N
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SR Sorin Rojea
- Dec 30, 2010 05:01 PM UTC
- Jan 5, 2011 02:34 PM UTC