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 11th, 2007, 02:22 PM
Authorized User
 
Join Date: Dec 2006
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default UserControl in DataGrid

Hi
Can i use a usercontrol as one of columns in DataGrid.
I have a Calendar user control and i need to use that calendar control in one of columns in datagrid.Here is my code but isn't working yet.Does someone has any suggestions/comments/ideas?
Thanks in advance.
Kamal
<asp:TemplateColumn HeaderText="Check Date">
<HeaderStyle HorizontalAlign="Center" ssClass="gridheader"></HeaderStyle>
<ItemStyle Width="5%"></ItemStyle>
<ItemTemplate>
<uc1:calendercontrol id="paiddate" runat="server"></uc1:calendercontrol>
</ItemTemplate>
</asp:TemplateColumn>
 
Old January 11th, 2007, 03:22 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Can you elaborate on "isn't working yet"?

Are you not seeing the control render?
Is it not posting back?

Please explain further.

-Peter
 
Old January 11th, 2007, 04:59 PM
Authorized User
 
Join Date: Dec 2006
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually it is working now.It was a silly silly mistake.But i have another issue related to the same thing.I am able to see the user control in grid but how do i bind it to the field in Database table.
This is what i am trying and it gives me date in ever row incremented 1 more than previous date.
    <asp:TemplateColumn HeaderText="Check Date"> <HeaderStyle HorizontalAlign="Center" CssClass="gridheader"></HeaderStyle> <ItemStyle Width="7%"></ItemStyle> <ItemTemplate> <uc1:calendercontrol id="paiddate" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CheckDate") %>'></uc1:calendercontrol>
    </ItemTemplate>
    </asp:TemplateColumn>
***********************************
The output that i see is like this
01/01/2007
02/01/2007
03/01/2007
04/01/2007......
Which is absolutely wrong.
***********************************
Thanks
Kamal
 
Old January 23rd, 2007, 05:52 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default

to bind data i think the only thing u can do is to declare property for this purpose in u'r usercontrol.Then assing the property according to binding.

Bijgupt
 
Old January 23rd, 2007, 03:09 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

What was the silly mistake? I make them too.

Thanks,
Richard

 
Old January 23rd, 2007, 03:22 PM
Authorized User
 
Join Date: Dec 2006
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Guys
I got the solution long time back.I am sorry i should have posted the reply by now.
Actually its like using any other control in the Grid.Its just that when it is User Control we need to register it and then declare it in .aspx.cs page.For instance i had a calender control so i had to declare that in .cs file with other variables as
protected calenderControl Check_Date;
where Check_Date is the User Control id defined in HTML.
And then like any other control the way to access this control is

CalenderControl cc=(CalenderControl)e.Item.FindControl("Check_Date ");
and then extract its value to another string or do whatever you have to with cc.

Hope this helps.

Hey Richard
let me know if this solves your silly mistake or i can explain it to you more with code.

Thanks
Kamal

 
Old January 23rd, 2007, 04:34 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Kamal,

Thank you for responding. There's a lot of people in this forum that spend a lot of their valuable time answering and responding to questions and then a lot of the time posters just say, "OK. Thanks, got it fixed" without saying what it was. Not only does it put the responders off but then no one else can benefit from the solution.

My silly mistakes are too numberous to mention. I don't have one in particular but they're usually very simple things like misspelling, or like yours, just forgetting to declare the variable or on the other end, forgetting to put the control on the front page.

So, much appreciated. Thanks.

Richard

 
Old January 23rd, 2007, 04:38 PM
Authorized User
 
Join Date: Dec 2006
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Richard
No problem ! Forms like these help me a lot at many stages.So this is just my way of helping others who might be lost like me .
But hey don't worry eventually you will see that you learnt everything from all those silly mistakes besides they make programming lots of fun.Imagine programming without them .

Take Care ...
Ciao
Kamal






Similar Threads
Thread Thread Starter Forum Replies Last Post
loaded usercontrol benordz C# 7 April 4th, 2008 09:16 AM
Get value of a QueryStringParameter in UserControl hpox ASP.NET 2.0 Basics 1 February 16th, 2007 11:54 AM
usercontrol in datagrid flickerslair ASP.NET 1.0 and 1.1 Basics 0 January 5th, 2006 11:59 AM
Datagrid paging in userControl pajer ASP.NET 1.0 and 1.1 Basics 4 October 14th, 2004 03:29 AM
Intellisense for UserControl RNedel ASP.NET 1.0 and 1.1 Basics 6 June 15th, 2004 04:47 AM





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