HowTo: DataGrid edit mode for template columns?

Discussion in 'ASP .Net' started by Alex, Apr 25, 2004.

  1. Alex

    Alex Guest

    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, Apr 25, 2004
    #1
    1. Advertising

  2. Alex wrote:
    > 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

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Apr 26, 2004
    #2
    1. Advertising

  3. Alex

    Alex Guest

    Thanks, works great!

    "Scott Mitchell [MVP]" <> wrote in message
    news:kq1jc.41203$...
    > Alex wrote:
    > > 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
    >
    > http://www.4GuysFromRolla.com
    > http://www.ASPFAQs.com
    > http://www.ASPMessageboard.com
    >
    > * When you think ASP, think 4GuysFromRolla.com!
     
    Alex, Apr 26, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Schultz
    Replies:
    3
    Views:
    596
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Feb 14, 2005
  2. Vincent
    Replies:
    1
    Views:
    473
    Lucas Tam
    Aug 17, 2005
  3. Anthony Peterson

    DataGrid Template Columns in VS 2003 Design Mode

    Anthony Peterson, Nov 1, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    464
    Anthony Peterson
    Nov 1, 2007
  4. Cahoo
    Replies:
    4
    Views:
    268
    Scott M.
    Aug 30, 2004
  5. Frank Kurka
    Replies:
    8
    Views:
    342
Loading...

Share This Page