User Controls in Datagrids

This is a discussion on "User Controls in Datagrids" within the ASP.NET Forum section. This forum, and the thread "User Controls in Datagrids are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > ASP.NET Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 7th, 2006, 15:49
New Member
Join Date: Aug 2006
Location: Stafford, UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy User Controls in Datagrids

Hi again,
I have developed user control that I can put on a page and it works no problem.
However, when I pull data out of a dataset into a datagrid and put user control within a template column, the control displays, but doesn't work; as in it cannot keep its state when it is supposed to do something.

This is my templateColumn...

Code: Select all
 
<asp:TemplateColumn headertext="Title">
         <ItemTemplate>
          <foxford:dbImg runat="server" imageid='<%# Container.DataItem("imgId") %>' alternatetext='<%# Container.DataItem("title") %>' /><br />
          <asp:hyperlink runat="server"
               text='<%# Container.DataItem("title") %>'
               href='<%# Container.DataItem("url") %>'
               target="_blank" />
         </ItemTemplate>
</asp:TemplateColumn>
As you can see, the control in question is my <foxford:dbImg> control which should do something whenever a button is pressed within it.

For your information, my control displays an image from a database with an "Edit" button. When the button is clicked it then should display a file upload field.

Any ideas?

Thanks, Steve
Reply With Quote

  #2 (permalink)  
Old Sep 7th, 2006, 19:24
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Re: User Controls in Datagrids

Off the top of my head, I think this is because when your control is clicked in the datagrid the postback cannot find the usercontrol because is is nested in the template. I dont know if this is gonna work, but look into the FindControl() method. Also what ?might? be if use is the OnItemDatabound event of the datagrid and casting your user control.

Hope that is of some help
Reply With Quote
  #3 (permalink)  
Old Sep 8th, 2006, 10:04
New Member
Join Date: Aug 2006
Location: Stafford, UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Re: User Controls in Datagrids

Thanks for your reply. It was useful, however didn't cure my problem hehe.

By my usual method of fixing bugs by sheer random acts of programming, I decided to stick if statements around my BindDataGrid method to see what happens...

Code: Select all
 
 if not isPostBack then
  BindDataGrid()
 end if
...and lo and behold, the controls started working! Yay

Steve
Reply With Quote
Reply

Tags
user, controls, datagrids

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Chart Controls marketer2007 ASP.NET Forum 1 May 21st, 2008 21:09
fl.controls.ComboBox could not be found grahame Flash & Multimedia Forum 6 Sep 21st, 2007 18:00
web controls in aspx ketansethi ASP.NET Forum 0 Aug 12th, 2007 09:46
ActiveX Controls vnswathi JavaScript Forum 0 May 22nd, 2006 14:23
Windowless controls / z-order ttupper Web Page Design 4 Nov 4th, 2005 14:54


All times are GMT. The time now is 21:00.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43