mardi 4 août 2015

How to save items from a CheckBoxList To dataBase

I am using a CheckBoxList that bind from database,

Now saving these values is becoming problematic.

I want to save the selected value to new data table, and than show the items that chacked.

<div style="position: absolute; left: 600px; top: 220px;">
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" Width="200px" TextAlign="Left" CssClass="mycheckbox" DataSourceID="SqlDataSource1" DataTextField="TypeGeare" DataValueField="IdGeare">
        </asp:CheckBoxList>
        <asp:SqlDataSource runat="server" ID="SqlDataSource1" 
        ConnectionString='<%$ ConnectionStrings:RegistrationConnectionString %>'
        SelectCommand="SELECT * FROM [InstituteGeare]" OnSelecting="SqlDataSource1_Selecting">
        </asp:SqlDataSource>
    </div>

<div style="position: absolute; left: 650px; top: 500px;">
<asp:Button ID="pricegearebtn" runat="server" Text="send " Height="50" Width="160" />
</div>

Another thing, I tried to creat a table with 2 forgien key, but without success. I get this error : "SQL72031 :: This deployment may encounter errors during execution because changes to [dbo].[GearReq].[UserId] are blocked by [dbo].[GearReq]'s dependency in the target database."

CREATE TABLE [dbo].[GearReq] (
[UserId] NVARCHAR(50) NOT NULL, 
[GearId] INT NULL
FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([Id]), 
FOREIGN KEY ([GearId]) REFERENCES [dbo].[InstituteGeare]([IdGeare])

);




Aucun commentaire:

Enregistrer un commentaire