[問題] GridView新增置資料庫的問題
我想用GridView加上一個button
按下button之後會抓該行資料以及一個DropDownList的值
存進另一個資料表
做是做出來了
按下新增都沒進到資料庫
但也沒有錯誤訊息
請問一下哪裡出了問題QQ
DropDwonList的部份
<asp:DropDownList ID="Role" runat="server" DataSourceID="SqlDataSource1"
DataTextField="Role_Title" DataValueField="Role_Title"
OnSelectedIndexChanged="Role_SelectedIndexChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:workConnectionString %>"
SelectCommand="SELECT [Role_Title] FROM [Role]">
</asp:SqlDataSource>
GridView的部份
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="3" DataKeyNames="num,id,name"
DataSourceID="SqlDataSource2"
OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
AllowPaging="True" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px">
<FooterStyle BackColor="White" ForeColor="#000066" />
<Columns>
<asp:BoundField DataField="num" HeaderText="編號"
InsertVisible="False" ReadOnly="True"SortExpression="num" />
<asp:BoundField DataField="id" HeaderText="帳號" SortExpression="id" />
<asp:BoundField DataField="name" HeaderText="姓名"
SortExpression="name" />
<asp:ButtonField ButtonType="Button" Text="新增" />
</Columns>
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999"
Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066"
HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:workConnectionString %>"
SelectCommand="SELECT [num], [id], [name],
[project], [user_group] FROM [work_user]"
OnSelecting="SqlDataSource2_Selecting"
InsertCommand="INSERT INTO Assignment(Project_number, Account, Name,
Role_Title) VALUES (@num, @id, @name, @Role_Title)">
<InsertParameters>
<asp:ControlParameter ControlID="GridView1"
Name="num" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1"
Name="id" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="GridView1"
Name="name" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="Role"
Name="Role_Title" PropertyName="SelectedValue" />
</InsertParameters>
</asp:SqlDataSource>
按下新增沒有錯誤訊息
但是也沒進資料庫= =
另外有寫一個刪除的
但是就可以Work
(但是不用抓DropDownList,直接刪除)
懇請大大幫個忙QQ
這幾天計畫案趕進度啊QQ
InsertCommand的Role_Title是要抓DropDownList的值
其他Account等等是要直接抓GridView1的值
--
▏▎▍▌▋▊▉ 一個人或許會孤單...▉▊▋▌▍▎▏
▏▎▍▌▋▊▉ 愛上一個人卻讓你更寂寞...▉▊▋▌▍▎▏
http://www.wretch.cc/album/Tony427
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.25.118.177
※ 編輯: Tony427 來自: 163.25.118.177 (07/02 02:16)
推
07/02 04:36, , 1F
07/02 04:36, 1F
推
07/02 04:37, , 2F
07/02 04:37, 2F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章