Gridview update with sqldatasource and dropdown

W

Will

I have searched and solutions that I have found are not working, I have
a datagrid that will be updating a mysql db. Now I have a drop down
that has a static collection but is dynamically selected to a selected
value thats in the database. I click the edit button in the gridview
and the drop down shows up fine, I pick a number in the drop down and
hit update it says at that new number but the database never
updates.....help anyone know why? Is there anyway to print the
updatecommand to the screen to show what values are going to the
database?

##################CODE################################
<asp:GridView ID="GridView1" AllowSorting="false"
AllowPaging="false" Runat="server"
DataSourceID="SqlDataSource1" AutoGenerateEditButton="true"
DataKeyNames="Team"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField ReadOnly="true" HeaderText="Team"
DataField="Team" />
<asp:TemplateField HeaderText="Rank" >
<ItemTemplate>
<asp:Label Runat="server" Text='<%#
Bind("trank") %>' ID="label2"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlPr" runat="server"
DataTextField="trank" DataValueField="trank" SelectedValue='<%#
Bind("trank") %>' >
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
<asp:ListItem>6</asp:ListItem>
<asp:ListItem>7</asp:ListItem>
<asp:ListItem>8</asp:ListItem>
<asp:ListItem>9</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
<asp:ListItem>13</asp:ListItem>
<asp:ListItem>14</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>16</asp:ListItem>
<asp:ListItem>17</asp:ListItem>
<asp:ListItem>18</asp:ListItem>
<asp:ListItem>19</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>21</asp:ListItem>
<asp:ListItem>22</asp:ListItem>
<asp:ListItem>23</asp:ListItem>
<asp:ListItem>24</asp:ListItem>
<asp:ListItem>25</asp:ListItem>
<asp:ListItem>26</asp:ListItem>
<asp:ListItem>27</asp:ListItem>
<asp:ListItem>28</asp:ListItem>
<asp:ListItem>29</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
ProviderName="<%$
ConnectionStrings:testConnectionString.ProviderName %>"
SelectCommand="Select prid, team, rank as trank, wins, loses, ties, otl
from power_rankings_holder"
UpdateCommand="UPDATE power_rankings_holder SET rank =
@trank WHERE prid = @prid">
</asp:SqlDataSource>
##################/CODE################################
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top