Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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
        }


Reply With Quote
  #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
Reply With Quote
Reply


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
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



All times are GMT -4. The time now is 08:26 AM.


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