HowTo: DataGrid edit mode for template columns?

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

I'm using a DataGrid with several bound columns. However for one column I
had to use a ItemTemplate with a asp:hyperlink in it.
How can I switch the hyperlink column into the edit mode in the datagrid
event handler?

Also, I sit possible to make not allow a field to be edited from within the
edit handler?
 
Alex said:
I'm using a DataGrid with several bound columns. However for one column I
had to use a ItemTemplate with a asp:hyperlink in it.
How can I switch the hyperlink column into the edit mode in the datagrid
event handler?

You need to provide an EditItemTemplate in the TemplateColumn.

<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink ... />
</ItemTEmplate>
<EditItemTemplate>
<asp:TextBox runat="Server" id="txtLinkEdit" Text='<%#
DataBinder.Eval(Container.DataItem, "hyperlinkFieldName")' />
</EditItemTemplate>
</asp:TemplateColumn>


To learn how to read the value of the edited TemplateColumn
programmatically, see:
http://datawebcontrols.com/faqs/ProgrammaticAccess/AccessingTemplateColumnContents.shtml

Happy Programming!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
Thanks, works great!

Scott Mitchell said:
You need to provide an EditItemTemplate in the TemplateColumn.

<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink ... />
</ItemTEmplate>
<EditItemTemplate>
<asp:TextBox runat="Server" id="txtLinkEdit" Text='<%#
DataBinder.Eval(Container.DataItem, "hyperlinkFieldName")' />
</EditItemTemplate>
</asp:TemplateColumn>


To learn how to read the value of the edited TemplateColumn
programmatically, see:
http://datawebcontrols.com/faqs/ProgrammaticAccess/AccessingTemplateColumnContents.shtml

Happy Programming!

--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 
Back
Top