ListBox array in UpdateCommand

Joined
Dec 10, 2010
Messages
2
Reaction score
0
Hi,
I have a C# project with a bound gridview using an Edit CommandField.

When the line item is marked for editing, the one cell has a ListBox (ID = SharCode) with SelectionMode = Multiple.

My UpdateCommand in my datasource for the gridview has a parameter called ShareCode (type = string).

But my problem is that is the user selects multiple option, only the first selected option is passed to the UpdateCommand.

I cant iterate through the options to see what is selected because i'm using a datasource for updating my gridview.

Is it possible to pass an array of selected items to the updatcommand of a datasource? Something like ShareCode[].

Has anyone done this before?

Any help appreciated...
Vauneen
 
Joined
Dec 10, 2010
Messages
2
Reaction score
0
Code below:
The List box itself looks like this:

Code:
 <asp:TemplateField ItemStyle-Width="40" HeaderStyle-HorizontalAlign="Center" HeaderText="Code" SortExpression="ShareCode">   
                    <EditItemTemplate>
                        <asp:ListBox SelectionMode="Multiple" Height="100" Width="80" Font-Size="10px" Font-Names="Arial" ForeColor="#222222" ID="ShareCode" runat="server" AutoPostBack="False" SelectedValue='<%# Bind("ShareCode") %>' >
                            <asp:ListItem Text="ABL" Value="ABL" ></asp:ListItem>
                            <asp:ListItem Text="AEG" Value="AEG" ></asp:ListItem>
    .....
                            <asp:ListItem Text="VOD" Value="VOD" ></asp:ListItem>
                        </asp:ListBox>      
                   </EditItemTemplate>
                    <ItemTemplate >       
                        <asp:Label Runat="server" Text='<%# Bind("ShareCode") %>' ID="ShareCode"></asp:Label>
                    </ItemTemplate>
                    </asp:TemplateField>
And then the Datasource looks like this:

Code:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DawnPatrolSQLConnection %>" 
        SelectCommand="....."
        UpdateCommand="UPDATE [tbl_NewsDawnPatrols] SET [securityIDvalue] = @ShareCode, [Discipline] = @DisciplineID, [News_Title] = @News_Title, [News_Subtitle] = @News_Subtitle, [Daily] = @Daily, [UpdatedByDataCapture] = 2, [RegionSub] = @RegionSub, [ProductType] = @ProductType, [Recommendation] = @Recommendation WHERE [NewsDawnPatrol_ID] = @NewsDawnPatrol_ID">
        <UpdateParameters>
            <asp:Parameter Name="News_Title" Type="String" />
            <asp:Parameter Name="News_Subtitle" Type="String" />
            <asp:Parameter Name="DisciplineID" Type="Int32" />
            <asp:Parameter Name="Recommendation" Type="String" />
            <asp:Parameter Name="NewsDawnPatrol_CreateDate" Type="DateTime" />
            <asp:Parameter Name="NewsDawnPatrol_ID" Type="Int32" />
            <asp:Parameter Name="UpdatedByDataCapture" Type="Int16" />
            <asp:Parameter Name="ShareCode" Type="String" />                
        </UpdateParameters>
    </asp:SqlDataSource>
Hope that's not too much info now.
Anyone with ideas? Pretty please....
Thanks,Vauneen
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top