473,770 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview update with sqldatasource and dropdown

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.....hel p 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="f alse"
AllowPaging="fa lse" Runat="server"
DataSourceID="S qlDataSource1" AutoGenerateEdi tButton="true"
DataKeyNames="T eam"
AutoGenerateCol umns="False">
<Columns>
<asp:BoundFie ld ReadOnly="true" HeaderText="Tea m"
DataField="Team " />
<asp:TemplateFi eld HeaderText="Ran k" >
<ItemTemplate >
<asp:Label Runat="server" Text='<%#
Bind("trank") %>' ID="label2"></asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st 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>1 0</asp:ListItem>
<asp:ListItem>1 1</asp:ListItem>
<asp:ListItem>1 2</asp:ListItem>
<asp:ListItem>1 3</asp:ListItem>
<asp:ListItem>1 4</asp:ListItem>
<asp:ListItem>1 5</asp:ListItem>
<asp:ListItem>1 6</asp:ListItem>
<asp:ListItem>1 7</asp:ListItem>
<asp:ListItem>1 8</asp:ListItem>
<asp:ListItem>1 9</asp:ListItem>
<asp:ListItem>2 0</asp:ListItem>
<asp:ListItem>2 1</asp:ListItem>
<asp:ListItem>2 2</asp:ListItem>
<asp:ListItem>2 3</asp:ListItem>
<asp:ListItem>2 4</asp:ListItem>
<asp:ListItem>2 5</asp:ListItem>
<asp:ListItem>2 6</asp:ListItem>
<asp:ListItem>2 7</asp:ListItem>
<asp:ListItem>2 8</asp:ListItem>
<asp:ListItem>2 9</asp:ListItem>
<asp:ListItem>3 0</asp:ListItem>
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>
<br />
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:testConnecti onString %>"
ProviderName="< %$
ConnectionStrin gs:testConnecti onString.Provid erName %>"
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:SqlDataSour ce>
############### ###/CODE########### ############### ######

Jan 12 '07 #1
0 1511

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5041
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
6
7074
by: tfsmag | last post by:
I have a Grid that I've set up to have two of the fields use dropdownlists while in edit mode. Now I can bind the data to the dropdownlists just fine. My problem is that the second dropdown depends on the first dropdown to pass a parameter to it. If I have a selectedvalue set to the second drop down, when i select a new value from the first drop down it gives me this error. "Databinding methods such as Eval(), XPath(), and Bind() can...
4
4493
by: P. Yanzick | last post by:
Hello, I've been playing with master/detail views as well as editing in the gridview, and I ran across a strange problem that I am not exactly sure where to go to try to solve. I have 2 tables, a table of cars (pretty basic, an ID, a description, and a Color ID) and a table of colors (Color ID, and a color description). I've added a gridview and a detailsview as I'm playing with both and how to get editing features to work the way I...
4
2044
by: Dabbler | last post by:
I need to convert a CompanyId in one table to Company Name from another table for an ItemTemplate. I thought I would just add another SqlDataSource but not sure how to eval with the CompanyId parameter for the where clause in the select. Any clues would be appreciated.
4
29539
by: Dabbler | last post by:
I have two tables I'm editing in a Gridview. The VANS table contains a key to the other LESSOR table. I would like to use a dropdown list to select the LessorId value while displaying the Lessor table's "Company" field as text. When I commit the edit I get error:Must declare the scalar variable "@LessorId". Also as a bonus question ;) I don't know how to set the selectedindex value in the dropdown list based on the LessorId value in the...
6
2395
by: Dabbler | last post by:
I have a GridView with a couple of TemplateFields. When I click the update link the Gridview returns to display mode with no errors but the data from bound text fields or dropdown list isn't updated in the table. I'm stumped and any help would be appreciated. Thanks much. My GridView: <asp:GridView ID="VanListGridView" runat="server"
2
3507
by: Tim Royal | last post by:
I'm using a GridView inside a Wizard Control with a textbox and two listboxes in the footer. I populate these listboxes from the database if the page isn't on postback (and the textbox is left blank initially). All of these controls have viewstate enabled. When the user fills out the textfield and clicks ADD, I do a check for validation of the data. If the user does not select a valid listbox entry, I abort the rest of the add, and make...
4
9790
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This sounds easy but the next requirement is that the GridView is editable. So I have included the SelectCommand and the UpdateCommand on the SqlDataSource to allow the GridView to be editable. I have now been able to get the GridView to display data...
3
2185
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a gridview that uses a sqldatasource. The rows of the gridview are editable. When the gridview is in edit mode, one of the columns is a dropdown. In testing the editing, I deleted the dropdown entry from one of the rows. So, when the gridview comes up, it shows nothing in the column where I deleted it. Then when I select to edit that same row, I get an error because I cannot select the value for the dropdown for a non-existing value....
0
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.