Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 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
 
Old January 16th, 2006, 03:03 PM
Registered User
 
Join Date: Jan 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bound Template Column in DataGrid

I have a datagrid that contains a dropdown list in a template columun.
Here's the HTML:

<asp:TemplateColumn HeaderText="Result">
    <ItemTemplate>
        <asp:DropDownList id="lstResultValue" runat="server">
            <asp:ListItem Value="Todo">Todo</asp:ListItem>
            <asp:ListItem Value="Pass">Pass</asp:ListItem>
            <asp:ListItem Value="Fail">Fail</asp:ListItem>
            <asp:ListItem Value="Unnecessary">Unnecessary</asp:ListItem>
            <asp:ListItem Value="Blocked">Blocked</asp:ListItem>
            <asp:ListItem Value="In Progress">In Progress</asp:ListItem>
        </asp:DropDownList>
    </ItemTemplate>
</asp:TemplateColumn>

It all works the way it should, changes get posted back to the database, etc. However, when the page loads, what shows in each cell in this column is the top item in the dropdown. What I want to show is the value for this field in the database, sort of a bound template column. It seems to me that that should be the default, but I can't find any way to do that.

Am I missing something obvious, or am I out of luck? A pointer to a C# code sample would be most helpful.

Thanks much,
Dennis


 
Old January 16th, 2006, 03:21 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

What I do, is put the value selected into a hidden datagrid field. This will store the value the user selected, on post back. Then, in the ItemDataBound event of the grid, I find that value(in the hidden column), and set the dropdown, using findbyvalue.

Jim

 
Old November 4th, 2006, 03:17 PM
Registered User
 
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

what is the code that you use in the ItemDataBound sub? I have been trying this for a week now
thanks







Similar Threads
Thread Thread Starter Forum Replies Last Post
Template Column in datagrid prankur ASP.NET 1.0 and 1.1 Professional 1 January 7th, 2006 05:20 PM
template column in datagrid p2pMember ASP.NET 1.0 and 1.1 Basics 1 November 18th, 2005 06:33 PM
Datagrid template column sonurijs ASP.NET 1.x and 2.0 Application Design 1 September 27th, 2005 12:55 PM
template column and bound column hidayah ASP.NET 1.x and 2.0 Application Design 1 April 9th, 2005 03:50 PM





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