By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,841 Members | 840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,841 IT Pros & Developers. It's quick & easy.

Gridview update with sqldatasource and dropdown

P: n/a
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.ProviderNam e %>"
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################################

Jan 12 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.