Friday, March 6, 2015

ASP.NET GridView ListBox Column Data Binding

[sourcecode language="c-sharp"]

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" CssClass="table" DataSourceID="GenericNamesDataSource" DataKeyNames="Id">

<Columns>

<asp:TemplateField HeaderText="Group Name" SortExpression="GroupName">
<EditItemTemplate>
<asp:ListBox ID="ListBox2" runat="server" DataSourceID="GroupsDataSource" DataTextField="Name" DataValueField="Id"  SelectedValue='<%# Bind("GroupId") %>' SelectionMode="Multiple" CssClass="chzn-select" autocomplete="off" data-placeholder="Select Item(s)"></asp:ListBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("GroupName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>

</Columns>

</asp:GridView>

<asp:SqlDataSource ID="GenericNamesDataSource" runat="server" ConnectionString='<%$ ConnectionStrings:flexi_stocky %>'
SelectCommand="SELECT GN.Id, GN.GroupId, GN.CreatedAt, G.Name AS GroupName FROM GenericNames AS GN INNER JOIN Groups AS G ON GN.GroupId = G.Id">

</asp:SqlDataSource>

<asp:SqlDataSource ID="GroupsDataSource" runat="server" ConnectionString='<%$ ConnectionStrings:flexi_stocky %>' SelectCommand="SELECT DISTINCT [Id], [Name] FROM [Groups]"></asp:SqlDataSource>

[/sourcecode]

1 comment:

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...