samedi 17 juin 2017

Build HyperLink url from CheckBoxes in a TemplateField?

I'm getting strings of emails from SQL and putting them in links, like so:

<asp:BoundField DataField="EmailList" DataFormatString="<a href='mailto:?bcc={0}'>&#9993;</a>" HeaderText="Email Members" HtmlEncodeFormatString="false" SortExpression="EmailList" />

I want to replace these links with checkboxes and have a single hyperlink that builds its URL from the checked rows. Here's what I've got:

<asp:GridView ID="GridView1" AllowPaging="True" AutoGenerateColumns="false" runat="server">
    <Columns>
        <asp:TemplateField SortExpression="EmailList">
            <HeaderTemplate>
                <asp:HyperLink NavigateUrl='<%# Bind("????", "mailto:?bcc={0}") %>' Text="&#9993;" runat="server" />
            </HeaderTemplate>
            <ItemTemplate>
                <asp:CheckBox ID="CheckBox1" OnCheckedChanged="Emails_Checked" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>

enter image description here

So, in this field, how can I bind data to the checkboxes and have the hyperlink access the data of checked boxes to add to its URL? How much of this can I get done with the web controls? Is there a better approach for this?

I'm new to web server controls; any help is appreciated.




Aucun commentaire:

Enregistrer un commentaire