set Focus on a programmatically created GridView

Hello,

how can I set a focus on a programmatically created gridview?
for example in gridview3 line 7?
GaialaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VelioCommented:
Hi Gaiala,

what do you mean by "set focus"? Set focus to the control as in calling the Focus() method, or select a row, as in setting the SelectedIndex property (seeing as how you want line 7)?
The fact that it's programatically created doesn't seem relevant to me.
0
vavjeevaCommented:
yes. you have focus() method for every control which you can use it.

if you use 1.1 framework , you can create your own method and use it.

Focus myFocus = new Focus();
myFocus.SetFocus(this.Button1,this);

1    public class Focus
2    {
3    
4        public void SetFocus(Control controlToFocus, Page webPageInstance)
5        {
6    
7    
8            StringBuilder scriptFunction = new StringBuilder();
9    
10           string scriptClientId;
11           scriptClientId = controlToFocus.ClientID;
12  
13           scriptFunction.Append(
14  
15           "<script language='javascript'>");
16           scriptFunction.Append(
17  
18           "document.getElementById('");
19           scriptFunction.Append(scriptClientId);
20  
21           scriptFunction.Append(
22  
23           "').focus();");
24           scriptFunction.Append(
25  
26           "</script>");
27           webPageInstance.ClientScript.RegisterStartupScript(GetType(),"SetFocusScript",scriptFunction.ToString()
28  
29           );
30  
31       }
32  
33   }

refer here
http://forums.asp.net/t/987325.aspx
0
GaialaAuthor Commented:
yes I mean
Set focus to the control as in calling the Focus() method

The fact that it's programatically created doesn't seem relevant to me.
ok but how can I get the Gridview I want to set the Focus?
0
VelioCommented:
how do you create the GridView?

presumably you will have to instantiate an object of type GridView, add it to a containter's (Page, Panel, etc)  Controls collection and set it up as you need it...
this means that you can either keep a variable to reference the GridView when you instantiate it, or you can find it in the container's Controls.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GaialaAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.