Advertisement

07.25.2008 at 10:40AM PDT, ID: 23596237
[x]
Attachment Details

c#.net gridview how do I add a clickable buttonfield to the header?

Asked by jackjohnson44 in .Net Editors & IDEs, Programming for ASP.NET, Microsoft Visual C#.Net

I am making a gridview programmatically since I am using it in a webpart.  This means that I CAN NOT make it in the designer, so please don't suggest that.

I want to be able to click on a header text so I can call a function.

How do I do this?

this is my code to generate the gridview:

            gv = new GridView();
            ods1 = new ObjectDataSource();
            gv.DataBound += new EventHandler(gv_DataBound);
            SetDataSource("Tagged Documents", 4, 1);
           
            gv.ID = "GridView1";
            gv.AutoGenerateColumns = false;
            gv.DataSourceID = "ObjectDataSource1";

            ButtonField bfld = new ButtonField();
            bfld.CommandName = "OpenDocument";
            bfld.DataTextField = "DocName";
            bfld.HeaderText = "Document";
            bfld.Text = "Button";

            BoundField boundFiled1 = new BoundField();
            boundFiled1.DataField = "DocModified";
            boundFiled1.HeaderText = "Modified";

            BoundField boundFiled2 = new BoundField();
            boundFiled2.DataField = "DocModifiedBy";
            boundFiled2.HeaderText = "Modified By";

            BoundField boundFiled3 = new BoundField();
            boundFiled3.DataField = "DocType";
            boundFiled3.HeaderText = "Type";
Start Free Trial
[+][-]07.28.2008 at 01:12AM PDT, ID: 22101392

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, Programming for ASP.NET, Microsoft Visual C#.Net
Sign Up Now!
Solution Provided By: davyquyo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.28.2008 at 06:59AM PDT, ID: 22103163

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628