Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 17th, 2006, 08:44 AM
Friend of Wrox
Join Date: Apr 2006
Location: , , .
Posts: 160
Thanks: 0
Thanked 0 Times in 0 Posts
Default strange problem with EditItemTemplate


It's about a table with two fields: 'team' and 'color'. Each team has a color.
What I want is to update the field 'color' in the gridview only with the selected value of the dropdownlist, which is bound to a table ('colortable') with one field ('allcolor') containing all available colors.

My problem is this:

When clicking on 'Edit' button in the gridview, the value shown into the <EditItemTemplate> in the gridview is always the first element of the dropdownlist ('pickup').
When clicking on 'Update' button, the field 'color' becomes empty.

In the <body>, i put <%=dd%> for testing the selected value of the dropdownlist, and the value is right on each click in the dropdownlist. So why does Text='<%#dd%>'in the <EditItemTemplate> only show the first value and why does the update not work ?

Thanks for any help

code in aspx:
this is used as test and shows the selected value of the dropdownlist:<%=dd %>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="..."
SelectCommand="SELECT * FROM [mytable]"
OldValuesParameterFormatString="original_{0}" ProviderName="System.Data.OleDb"
UpdateCommand = "UPDATE [mytable] SET [color] = ? where [team] = ?" >
                <asp:Parameter Name="team" Type="String" />
                <asp:Parameter Name="color" Type="String" />

                <asp:Parameter Name="original_team" Type="String" />
                <asp:Parameter Name="original_color" Type="String" />

<asp:GridView ID="GridView1" runat="server" DataKeyNames="field1" DataSourceID="SqlDataSource1" >
    <asp:CommandField ShowEditButton="True"/>
    <asp:BoundField DataField="team" />
    <asp:TemplateField HeaderText="color">
        <asp:Label ID="kl" Runat="server" Text='<%# Bind("color") %>'></asp:Label>

        <asp:TextBox ID="kl" ReadOnly="True" Runat="server" Text='<%#dd%>'> </asp:TextBox>

<asp:DropDownList ID="drd"
runat="server" AutoPostBack="True">

friend dd as string
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim d As OleDbDataAdapter
            Dim ds As DataSet
            Dim sConnectionString As String
            Dim sql, kl As String
            Dim z As ListItem
            Dim x, i As Integer
sConnectionString = "Provider = ...
sql = "SELECT [allcolor] FROM [colortable];"
d = New OleDbDataAdapter(sql, sConnectionString)
ds = New DataSet()
x = d.Fill(ds)

            If Page.IsPostBack Then
                dd = drd.SelectedValue
            End If

z = New ListItem("pick up a color", "pickup")
For i = 0 To x - 1
kl = ds.Tables(0).Rows(i).Item(0)
z = New ListItem(kl, kl)
End Sub

End Class


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
strange IE problem sully7 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 September 19th, 2008 08:44 AM
Strange problem... F3553 C++ Programming 1 October 25th, 2007 03:56 PM
problem with dropdownlist in editItemTemplate hertendreef ASP.NET 2.0 Professional 4 July 31st, 2007 05:56 PM
Strange calculation problem blkskullwork Javascript 4 November 3rd, 2006 03:16 PM
very strange problem! please help! raybristol ASP.NET 1.0 and 1.1 Basics 8 December 15th, 2005 06:46 AM

All times are GMT -4. The time now is 04:37 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.