Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 December 15th, 2004, 12:01 PM
Authorized User
 
Join Date: Jul 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataGrid template column

is there a way to control where the DataGrid's <asp:TemplateColumns> appear under <Columns>? Say I want a template column to be displayed after the automatic generated columns. How do I specify that under <Columns>. Please advise.
YUBO

 
Old December 15th, 2004, 12:54 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can't do that. Autogenerated columns come after predefined columns.
 
Old December 16th, 2004, 05:35 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

well,dont use Autogenerated columns,you can use <asp:BoundColumn> instead and change the order of your columns manually.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 
Old December 16th, 2004, 11:46 AM
Authorized User
 
Join Date: Jul 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In order to use 'AllowSorting="True"', autogenerated columns has to be set to "true". <asp:BoundColumn> won't work in this senario.

Quote:
quote:Originally posted by mehdi62b
 well,dont use Autogenerated columns,you can use <asp:BoundColumn> instead and change the order of your columns manually.

_____________________________
Mehdi.
software engineering student.
Looking for a good job for summer 2005.
 
Old December 19th, 2004, 01:56 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is not correct. You can allow sorting on your user defined columns (bound or other types of columns), you simply need to provide your own sort expressions for the columns you define.
 
Old December 21st, 2004, 01:59 AM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi all
i have created to template column.
if i put both temple column at last position then it works fine.
but if a change order of temple column then it gives error.
here is the code:
<asp:datagrid id="dgViewHedge" runat="server" Width="797px" BorderColor="#999999" BorderStyle="None"
                                        BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Vertical" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False"
                                        PageSize="3">
                                        <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle>
                                        <AlternatingItemStyle BackColor="Gainsboro"></AlternatingItemStyle>
                                        <ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle>
                                        <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle>
                                        <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle>
                                        <Columns>
                                            <asp:BoundColumn Visible="False" DataField="intComplianceAccountID" ReadOnly="True"></asp:BoundColumn>
                                            <asp:BoundColumn Visible="False" DataField="intAccountTypeCodeID" HeaderText="Account Type CodeID"></asp:BoundColumn>
                                            <asp:BoundColumn Visible="False" DataField="intSecurityTypeCodeID" HeaderText="Security Type CodeID"></asp:BoundColumn>
                                            <asp:BoundColumn DataField="vchOrganizationName" SortExpression="vchOrganizationName" HeaderText="Organization Name"></asp:BoundColumn>
                                            <asp:TemplateColumn HeaderText="Invetment Type">
                                                <ItemTemplate>
                                                    <asp:DropDownList id="DropDownList1" runat="server"></asp:DropDownList>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:DropDownList id="DropDownList2" runat="server"></asp:DropDownList>
                                                </EditItemTemplate>
                                            </asp:TemplateColumn>
                                            <asp:BoundColumn DataField="vchInvestmentDate" SortExpression="vchInvestmentDate" HeaderText="Investment Date"></asp:BoundColumn>
                                            <asp:TemplateColumn HeaderText="Securities Type">
                                                <ItemTemplate>
                                                    <asp:DropDownList id="DropDownList3" runat="server"></asp:DropDownList>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <asp:DropDownList id="DropDownList4" runat="server"></asp:DropDownList>
                                                </EditItemTemplate>
                                            </asp:TemplateColumn>
                                            <asp:BoundColumn DataField="mnyAmount" SortExpression="mnyAmount" HeaderText="Amount"></asp:BoundColumn>
                                            <asp:ButtonColumn Text="Delete" HeaderText="Delete" CommandName="Delete"></asp:ButtonColumn>
                                        </Columns>
                                        <PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></PagerStyle>
                                    </asp:datagrid>

When i execute the code it gives me "invalid cast error"?
but if change the order of both template column to last poistions then work fine!

how can put multiple template columns at different positions?
And how ro solve above error?

 
Old December 21st, 2004, 04:47 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Where are you getting this cast error?
 
Old December 21st, 2004, 11:35 PM
Registered User
 
Join Date: Dec 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

On page_load event i assigned a data source to Datagrid. I m getting this error on datagrid.DataBind() statement.
 
Old December 28th, 2004, 11:08 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

There doesn't appear to be anything wrong with your datagrid markup from what I can tell.





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
Buttons in DataGrid Template Column divsalar ASP.NET 1.x and 2.0 Application Design 1 February 1st, 2005 03:37 PM
Template Column in DataGrid and Button divsalar ASP.NET 1.x and 2.0 Application Design 1 January 23rd, 2005 12:43 AM





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