I am doing the same thing as you but with a GridView. I am able to get the fields to display data but not update by creating a custom TemplateField class. I see this was done a while back, so if you are still interested, I'll post code as to what I have done
so far. The only thing I cannot do is get data to bind going back to the datasource on the update command.
Raptor Development, Inc.
http://www.raptordev.com
Your Business Technology Partner
I can get this to work perfectly when i don't use ItemTemplates for my textbox edit controls. When I use BoundFields, the whole process works just fine. The only thing is I don't have any control over the width of the text box. That was the whole reason
for me going to an ItemTemplate. I have other messages out to see how I can programmatically set the ControlStyle member of the BoundField class just to get out of this nightmare.
Raptor Development, Inc.
http://www.raptordev.com
Your Business Technology Partner
I can get this to work perfectly when i don't use ItemTemplates for my textbox edit controls. When I use BoundFields, the whole process works just fine.
Yep, again, exactly the same issue I had. I could do absolutely everything, but define how to setup 2-way databinding (that is, being able to pull data out, as well as push data back in) with *programmatically* created template fields.
As an aside, you could easily use CSS to get around your problems
DaRKoN_
Member
45 Points
10 Posts
creating 2-way databinding templatefields programmatically
May 25, 2006 09:02 AM|LINK
I have a detailsview control which I am adding fields to programmatically.
I can add in template fields, but I cannot for the life of me figure out a way to Bind them to the datasource?
Declarativly, the below works perfectly fine, and updates back to the datasource..
<asp:TemplateField HeaderText="body" SortExpression="body">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" TextMode="MultiLine" runat="server" Text='<%# Bind("body") %>' />
</EditItemTemplate>
</asp:TemplateField>
But how can you do it programmatically? How can i specifcy what to bind it against?
DaRKoN_
Member
45 Points
10 Posts
Re: creating 2-way databinding templatefields programmatically
May 25, 2006 01:40 PM|LINK
no one has any idea if this is possible?
KaptainKen
Member
82 Points
15 Posts
Re: creating 2-way databinding templatefields programmatically
Jul 11, 2006 06:09 PM|LINK
http://www.raptordev.com
Your Business Technology Partner
DaRKoN_
Member
45 Points
10 Posts
Re: creating 2-way databinding templatefields programmatically
Jul 11, 2006 06:27 PM|LINK
I gave up :)
Let me know if you have any further success.
KaptainKen
Member
82 Points
15 Posts
Re: creating 2-way databinding templatefields programmatically
Jul 11, 2006 07:01 PM|LINK
DaRKoN_,
I can get this to work perfectly when i don't use ItemTemplates for my textbox edit controls. When I use BoundFields, the whole process works just fine. The only thing is I don't have any control over the width of the text box. That was the whole reason for me going to an ItemTemplate. I have other messages out to see how I can programmatically set the ControlStyle member of the BoundField class just to get out of this nightmare.
http://www.raptordev.com
Your Business Technology Partner
DaRKoN_
Member
45 Points
10 Posts
Re: creating 2-way databinding templatefields programmatically
Jul 11, 2006 07:14 PM|LINK
Yep, again, exactly the same issue I had. I could do absolutely everything, but define how to setup 2-way databinding (that is, being able to pull data out, as well as push data back in) with *programmatically* created template fields.
As an aside, you could easily use CSS to get around your problems
#gridIDname input
{
width:100px;
}
for example.
benfinkel
Member
66 Points
58 Posts
Re: creating 2-way databinding templatefields programmatically
Nov 12, 2009 05:13 PM|LINK
I realize this is an old topic but I came across it searching for the same answer. I have resolved the problem for myself, see my post here:
http://forums.asp.net/p/1492028/3509400.aspx#3509400
Short Story: Override the RowUpdating event (or FormUpdating or whatever control you're using) and add the fields manually to the keys.