We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Set focus in edit mode

Thread ID:

Created:

Updated:

Platform:

Replies:

97723 Dec 30,2010 12:01 PM Jan 5,2011 09:34 AM ASP.NET Web Forms (Classic) 3
loading
Tags: GridGroupingControl
Sorin Rojea
Asked On December 30, 2010 12:01 PM

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();
}
}
}
}
}
}
}




Sridhar N [Syncfusion]
Replied On December 31, 2010 02:17 AM

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#]


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




Sorin Rojea
Replied On January 4, 2011 09:09 AM

It worked, thank you!


Sridhar N [Syncfusion]
Replied On January 5, 2011 09:34 AM

Hi Sorin,

We are happy to hear that your issue is solved.Thanks for your reply.

Regards,
Sridhar.N


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;