471,354 Members | 1,190 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Programmatic set GridView1 SelectedIndexChanged

I am having trouble programmatically setting the SelectedIndexChanged
of a GridView.

Code as follows.
Panel Panel1 = new Panel();
GridView g = new GridView();
ObjectDataSource o = new ObjectDataSource();
//load objectdatasource using webservice
o.SelectMethod = "getAllCCF";
o.TypeName = "testitoccfws.PDAFServices";
//Bind to Gridview
o.DataBind();
g.AutoGenerateSelectButton = true;
g.DataSource = o;
g.DataBind();
g.SelectedIndexChanged += new
System.EventHandler(this.GridView1_SelectedIndexCh anged()); ----This
line has an error
Panel1.Controls.Add(g);

here is the method i wish to handle the event.
void GridView1_SelectedIndexChanged(object sender, e)
{
GridViewRow row = o.SelectedRow;
TextBox1.Text = row.Cells[1].Text;
}

Can someone please take a look and please tell me what I am doing
wrong?

Thanks,

KC

Jan 19 '06 #1
2 6641
Netmonster,
if you type "g.SelectedIndexChanged +=" and then hit the TAB key 2X,
the IDE will fill in everyting correctly for you.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Netmonster" wrote:
I am having trouble programmatically setting the SelectedIndexChanged
of a GridView.

Code as follows.
Panel Panel1 = new Panel();
GridView g = new GridView();
ObjectDataSource o = new ObjectDataSource();
//load objectdatasource using webservice
o.SelectMethod = "getAllCCF";
o.TypeName = "testitoccfws.PDAFServices";
//Bind to Gridview
o.DataBind();
g.AutoGenerateSelectButton = true;
g.DataSource = o;
g.DataBind();
g.SelectedIndexChanged += new
System.EventHandler(this.GridView1_SelectedIndexCh anged()); ----This
line has an error
Panel1.Controls.Add(g);

here is the method i wish to handle the event.
void GridView1_SelectedIndexChanged(object sender, e)
{
GridViewRow row = o.SelectedRow;
TextBox1.Text = row.Cells[1].Text;
}

Can someone please take a look and please tell me what I am doing
wrong?

Thanks,

KC

Jan 19 '06 #2
Dont I feel stupid...... LOL thanks

KC

Jan 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Blaine Manyluk | last post: by
2 posts views Thread by cmrchs | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.