Is it possible to make a gridview with a dropdownlist as one new control?

It depends on your definition of a "new GridView". The answer is yet, but at a cost.

It depends on your definition of a "new GridView". The answer is yet, but at a cost. If you base your control on WebControl, you can write a new grid control with any functionality.

Somehow, I don't think this is what you have in mind. If you want to inherit from the existing GridView and add extra controls, then it is also doable, but with heavy limitations. The reason is because GridView's implementation breaks every possible guideline for extensibility.

I guess because they never meant it to be extended. For instance, they clear Controls collection almost on every occasion and explicitly expect for the Controls0 to be a Table. I suppose, if you decide to stay within confines of the table layout (header, footer and all), then you may have more room to play.

Finally, you could create a wrapper, which has a GridView as its private member and simply expose everything you may need plus more. But that gets ugly very quickly. Here is a crude demonstration (working) of the second approach.

Note that the drop down is at the end. You can override the Render method, but you'd have to recreate a lot of MS code. ExtendedGridView public class ExtendedGridView : GridView { protected DropDownList DropDown { get; set; } public ExtendedGridView() : base() { this.

DropDown = new DropDownList(); this.DropDown.Items. Add("white"); this.DropDown.Items. Add("red"); this.DropDown.Items.

Add("blue"); this.DropDown.Items. Add("green"); this.DropDown. AutoPostBack = true; this.DropDown.ID = "dropdown"; this.DropDown.

SelectedIndexChanged += new EventHandler(DropDown_SelectedIndexChanged); } void DropDown_SelectedIndexChanged(object sender, EventArgs e) { BackColor = System.Drawing.Color. FromName(this.DropDown. SelectedValue); } protected override int CreateChildControls(System.Collections.

IEnumerable dataSource, bool dataBinding) { int itemCount = base. CreateChildControls(dataSource, dataBinding); Controls. Add(this.

DropDown); return itemCount; } } SomePage. Aspx SomePage.aspx.Cs protected void Page_Load(object sender, EventArgs e) { myGridView. DataSource = new string { "aaa", "bbb", "ccc", "ddd", "eee" }; myGridView.

AllowPaging = true; myGridView. PageSize = 2; myGridView.DataBind(); } protected void myGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { myGridView. PageIndex = e.

NewPageIndex; myGridView.DataBind(); }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions