Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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
  #1 (permalink)  
Old August 3rd, 2005, 08:06 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: , , .
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default datasource for dropdown in datagrid



Hi

i am displaying rows in datagrid.Here dropdownlist source will depend on first column of datagrid.So i have to pass the parameter to Dropdown datasource function.I tried like below but getting error like server tag not formed well.
pl correct me.

thanks


<asp:datagrid id="DG" runat="server" AlternatingItemStyle-BackColor="#ECF5FF" CssClass="DataPageTableData"
                        CellPadding="3" AutoGenerateColumns="False" AllowSorting="True" BorderStyle="None" HeaderStyle-CssClass="DataGridFixedHeader"
                        HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Left" Width="331px" Height="25px"
                        Visible="true">
                        <AlternatingItemStyle CssClass="DataPageTableDataDark"></AlternatingItemStyle>
                        <HeaderStyle HorizontalAlign="Left" CssClass="DataGridFixedHeader" VerticalAlign="Middle"></HeaderStyle>
                        <Columns>

                    <asp:ButtonColumn Text="Select" DataTextField="c_transformstatus" HeaderText="STATUS" CommandName="Select"></asp:ButtonColumn>

                            <ItemTemplate>
                                <asp:DropDownList AutoPostBack = True id = "DD" DataSource="<%# BindTheError(DataBinder.Eval(Container.DataItem, "c_transformstatus")) %>" DataTextField="c_levelname" DataValueField="c_transformstatus" Runat =server />
                            </ItemTemplate>
                            </asp:TemplateColumn>
                        </Columns>

                    </asp:datagrid>


.cs file code


        public DataView BindTheError(string status)
        {
            here code for returning the datatable
        }


  #2 (permalink)  
Old August 8th, 2005, 08:17 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

When you need to put a data binding reference inside a control attribute you need to put it in single quotes. It seems like an odd requirement, but that's what it takes:

<asp:DropDownList AutoPostBack = True id = "DD" DataSource='<%# BindTheError(DataBinder.Eval(Container.DataItem, "c_transformstatus")) %>' DataTextField="c_levelname" DataValueField="c_transformstatus" Runat =server />

-Peter


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataTable from DataGrid.DataSource Jamal Junior ASP.NET 2.0 Basics 1 March 24th, 2006 01:51 AM
Converting a DataGrid.DataSource to a DataView demivolt ASP.NET 1.0 and 1.1 Professional 10 July 8th, 2005 12:00 PM
DataGrid DataSource is Undefined. ochanarachel Classic ASP Basics 1 February 22nd, 2005 06:10 PM
DropDown in DataGrid kiranpanjala Classic ASP Databases 0 January 24th, 2005 10:54 AM
Datagrid functionality without a datasource cesherman VS.NET 2002/2003 1 July 7th, 2003 11:21 PM





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