Insert BoundField into DetailsView - asp.net

Basically I have a detailsview, dependent on what query it is I have certain BoundFields I'd like to show or hide.
Using visual basic, I know that I can use .visible = false. That does the trick, however, it sacrifices my alternating row style in the process.
Any ideas?
Thanks
By the way if you write it in C# I will probably understand.

What you need to do is create several asp:panel objects. Inside each panel object, put a single DetailsView. In your codebehind, you will want to show the panel that contains the proper DetailsView for your query, and hide the rest of the panels.

Related

How to pass values between asp.net pages with gridviews

I enabled the selection on my gridview. The question is, I can pass values with buttons but it seems redundant, because I have selection linkbuttons. So how can I pass variables with them ?
This example shows how to work with LinkButton in GridView and pass / transfer variable or data to other page and populate another gridview based on it using QueryString and QueryStringParameters. What's more, there is no need of any code behind. Pretty cool.

Does there exist a multiple select dropDownList for asp.net?

I'd like to have a DropDownList that has a CheckBox next to each item that would allow multiple to be selected. I did a little poking around but haven't found anything that will do this, does anyone know if this can be easily achieved?
I know it can be done with a listBox, but would prefer the dropdown format to save space.
Have a look at the DropDown control from the ASP.NET AJAX toolkit: It allows you to put arbitrary controls into a dropdown-like interface. I didn't try it, but I think that it should work to put a CheckBoxList in there.
I've never seen a multi-select DropDownList on any platform. How do you want it to work?
I'm sure some clever javascript could create one.

Using a TemplateField inside a web user control

Is it possible to use a TemplateField (or any *Field from a GridView) inside a user control (ascx).
I have a complex TemplateField (item, edit, footer) that I would like to easily reuse.
Thanks.
As the question is worded, there is no way. What it sounds like you are doing (making the elements of a TemplateColumn reusable) then there are two ways that come to mind right off.
One, put your User Control into the ItemTemplate/FooterTemlate of the TemplateColumn.
Two, build the complex GridView Column as a standalone server control, which you can use in place of a TemplateColumn (or BoundColumn).
GridView is a bit top-heavy for a user control - you could create a custom GridView in a separate control library and simply reuse it that way.

GridView Making a single Edit Item Template take the entire row

I've got this gridview. The gridview uses TemplateFields as the number of fields in the database's table. What I do next is use an ItemTemplate to present the correct column info.
Now, problems rise when the user click's Edit. Since I can only use EditItemTemplate to edit I am resulted with a control in each column. What I really want is to have a single row with no columns so I can easily style the edit mode (having a table with a different layout for example).
Is this possible? If so, how?
I suspect you will have to create your own specialized class that inherits from GridView and does its own rendering to accomplish this.
You might hack some workaround though... such as manually editing the rendered HTML output or DOM.

"Action" column in a DataReader

I have an "action" column in my repeater which shows actions a user can select for an item. The column contains ASP.NET HyperLink or LinkButton controls. Some actions are based on whether a user is in a role, which I determine programatically. I'm struggling with the best way to dynamically generate this column when I populate the repeater. Now I am assigning in-line code to the Visible property of each control, but I feel that is sloppy and not very straight forward. Would I be better served using a PlaceHolder control and populating that at runtime? What kind of methods do other people use for situations such as this?
The "normal" way to apply any sort of dynamic rendering to a Template based control such as the Repeater is to handle the ItemCreated or ItemDataBound events.
In your particular case, you could check appropriate conditions within that event handler and toggle the visibility of the relevant "Action" column.
Also, see this question where Ian Quigley posted a code snippet that should serve as a good example for you. It may also help to read my own answer which shows how to use visibility toggling in inline code.

Resources