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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set focus to textbox in a DataGrid

Status
Not open for further replies.

livezone

MIS
Jan 17, 2003
81
CA
Hi,

How can I set focus to a text box inside the datagrid. Text box name is "newUPC".

Thanks
Shafiq
 
Use the .focus javascript method


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I know that too.
But the text box in datagird has different id than their actual name

for newUPC the name may be look like
dgrdOrder__ctl2_newUPC. I mean how to find out the control first
 
You could use the FindControl method in one of the DataGrid events and the user Page.RegisterStartUpScript to add the relevant javascript function.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I am still confused.
Text box is in the Footer of datagrid. I can find the control using

If e.Item.ItemType = ListItemType.Footer Then
Dim tb As TextBox
tb = CType(e.Item.FindControl("newUPC"), TextBox)
End If

But I need to focus this text field only when the page reload. Where should I put the code
Thanks
Shafiq
 
Did you get this solved? If not then what do you mean only when the page reload?

Something like...

In the formload event:

If page.ispostback then
yourcode
End

I think I can help you out here because I have had to give focus like this before, just give me a little more info, if you haven't already figured it out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top