Binding a GridView to a Dynamic or ExpandoObject object

Since you can’t bind to an ExpandoObject, you can convert the data into a DataTable. This extension method will do that for you. I might submit this for inclusion to Massive. /// <summary> /// Extension method to convert dynamic data to a DataTable. Useful for databinding. /// </summary> /// <param name=”items”></param> /// <returns>A DataTable with … Read more

How to set different columns for rows in android gridview

I have something similar and i solved with the new RecyclerView. I created a Fragment with an a RecyclerView. RecyclerView on xml: <android.support.v7.widget.RecyclerView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:id=”@+id/filter_subtypes” android:layout_width=”match_parent” android:layout_height=”match_parent” /> On your Fragment/Activity (OnViewCreated in my fragment case). I find the RecyclerView and set an Adapter- a normal Adapter class inherit from RecyclerView.Adapter< YOUR VIEW HOLDER … Read more

Full postback triggered by LinkButton inside GridView inside UpdatePanel

You need to register each and every LinkButton as an AsyncPostBackTrigger. After each row is bound in your GridView, you’ll need to search for the LinkButton and register it through code-behind as follows: protected void OrderGrid_RowDataBound(object sender, GridViewRowEventArgs e) { LinkButton lb = e.Row.FindControl(“MarkAsCompleteButton”) as LinkButton; ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb); } This also requires that ClientIDMode=”AutoID” be set … Read more

Conditionally hide CommandField or ButtonField in Gridview

First, convert your ButtonField or CommandField to a TemplateField, then bind the Visible property of the button to a method that implements the business logic: <asp:GridView runat=”server” ID=”GV1″ AutoGenerateColumns=”false”> <Columns> <asp:BoundField DataField=”Name” HeaderText=”Name” /> <asp:BoundField DataField=”Age” HeaderText=”Age” /> <asp:TemplateField> <ItemTemplate> <asp:Button runat=”server” Text=”Reject” Visible=”<%# IsOverAgeLimit((Decimal)Eval(“Age”)) %>” CommandName=”Select”/> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> Then, in the code … Read more

Best way to make WPF ListView/GridView sort on column-header clicking?

I wrote a set of attached properties to automatically sort a GridView, you can check it out here. It doesn’t handle the up/down arrow, but it could easily be added. <ListView ItemsSource=”{Binding Persons}” IsSynchronizedWithCurrentItem=”True” util:GridViewSort.AutoSort=”True”> <ListView.View> <GridView> <GridView.Columns> <GridViewColumn Header=”Name” DisplayMemberBinding=”{Binding Name}” util:GridViewSort.PropertyName=”Name”/> <GridViewColumn Header=”First name” DisplayMemberBinding=”{Binding FirstName}” util:GridViewSort.PropertyName=”FirstName”/> <GridViewColumn Header=”Date of birth” DisplayMemberBinding=”{Binding DateOfBirth}” … Read more

How to have a GridView that adapts its height when items are added

Use this code public class MyGridView extends GridView { public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }