Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set focus in gridview when in edit mode

Status
Not open for further replies.

njb

Programmer
Mar 17, 2000
38
US
When a gridview row is placed in edit mode, is there a way to set the focus to a control being edited? I've tried and am not having a lot of success. There is only one field being updated. That portion of the gridview is listed below. I would like the cursor to be placed at the RMKS control when it is being edited. Thanks for any help that can be given.

Code:
<asp:TemplateField HeaderText="Remarks" SortExpression="RMKS" ItemStyle-Wrap="true"
                        ItemStyle-Width="55%">
                        <ItemTemplate>
                            <asp:Label runat="server" Text='<%# Eval("RMKS") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="RMKS" runat="server" Text='<%# Bind("RMKS") %>' TextMode="MultiLine"
                                Height="300" Width="100%"></asp:TextBox>
                        </EditItemTemplate>
                        <ItemStyle Wrap="True" VerticalAlign="Top"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField ShowHeader="False">
                        <EditItemTemplate>
                            <asp:Button ID="btnUpdate" runat="server" CausesValidation="True" CommandName="Update"
                                Text="Update" />&nbsp;
                            <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                                Text="Cancel" />
                        </EditItemTemplate>
                        <ItemStyle VerticalAlign="Top" />
                    </asp:TemplateField>
 
i believe webcontrols, at least visual webcontrols, has a setfocus method to created the required js.

create a handler for EditingGridViewRow
in this member find the control you are looking for.
call SetFocus (if the member doesn't exist you will need to downcast to the appropriate type)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top