473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

HowTo: DataGrid edit mode for template columns?

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?
Nov 18 '05 #1
2 1801
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/Prog...Contents.shtml

Happy Programming!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
Nov 18 '05 #2
Thanks, works great!

"Scott Mitchell [MVP]" <mi******@4guysfromrolla.com> wrote in message
news:kq*******************@newssvr29.news.prodigy. com...
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/Prog...Contents.shtml
Happy Programming!

--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Richard Roche | last post by:
Is it possible to use a drop combo instead of a text box when using the EditCommand in the Datagrid? Many table columns are bound to 'lookup' tables, user's don't care about the foreign keys,...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
by: localhost | last post by:
When I go into Edit mode on a datagrid, I would like to add a single column to the edited row and display a hyperlink. If I use the code below, I get a delete linkbutton in every row, when I only...
2
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last,...
2
by: CW | last post by:
In an earlier thread, I was asking for help on "Invalid attempt to FieldCount when reader is closed" error when I was using a dataset rather than a datareader to bind to a datagrid. After...
3
by: Leo | last post by:
I have a datagrid with the first column as a Edit,Update,Cancel button column. The other 5 columns are template columns. When I click the Edit button in IE6 the row correctly displays the...
3
by: CharlesA | last post by:
Hi folks, I really need help with the following scenario, I'm going to describe as well as a I can what the setup is and what I can't understand I'm using the framework 1.1 using ASP.net with...
6
by: Scott McDaniel | last post by:
I'm using Visual Studio 2005 with the .NET 2.0.50727 framework, and we're using the standard Datagrid control bound to a SQL Server. We have two groups of users - "full edit" users, and "view...
8
by: =?Utf-8?B?bWlrZWc=?= | last post by:
Hi, I am building a small Help Desk application for my company and need to be able to edit "open" help desk issues. I use a simple datagrid to display each issue (6 per page) , with an Edit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.