473,405 Members | 2,187 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,405 software developers and data experts.

How to put a GridView's row in edit mode, programatically?

ata
Hi folks,
I've got a LinkButton that's being added to the GridView under certain
circumstances, conditionally.
Whenever the link is clicked, I would like to put the row (that
contains the link) in edit mode.
Please note that I'm trying to do this dynamically, in the run-time.

Any help would be highly appreciated,

Thanks
Jack
Jun 27 '08 #1
4 2837
Just make sure that your linkbutton has the property CommandName="Edit".

--

Riki

<at*@mailinator.comwrote in message
news:bc**********************************@e53g2000 hsa.googlegroups.com...
Hi folks,
I've got a LinkButton that's being added to the GridView under certain
circumstances, conditionally.
Whenever the link is clicked, I would like to put the row (that
contains the link) in edit mode.
Please note that I'm trying to do this dynamically, in the run-time.

Any help would be highly appreciated,

Thanks
Jack

Jun 27 '08 #2
ata
On Jun 6, 8:43 pm, "Riki" <r...@dontnagme.comwrote:
Just make sure that your linkbutton has the property CommandName="Edit".

--

Riki

<a...@mailinator.comwrote in message

news:bc**********************************@e53g2000 hsa.googlegroups.com...
Hi folks,
I've got a LinkButton that's being added to the GridView under certain
circumstances, conditionally.
Whenever the link is clicked, I would like to put the row (that
contains the link) in edit mode.
Please note that I'm trying to do this dynamically, in the run-time.
Any help would be highly appreciated,
Thanks
Jack
But it doesn't make either.
Jun 27 '08 #3
ata
On Jun 6, 8:43 pm, "Riki" <r...@dontnagme.comwrote:
Just make sure that your linkbutton has the property CommandName="Edit".

--

Riki

<a...@mailinator.comwrote in message

news:bc**********************************@e53g2000 hsa.googlegroups.com...
Hi folks,
I've got a LinkButton that's being added to the GridView under certain
circumstances, conditionally.
Whenever the link is clicked, I would like to put the row (that
contains the link) in edit mode.
Please note that I'm trying to do this dynamically, in the run-time.
Any help would be highly appreciated,
Thanks
Jack
Well, I did so, but it doesn't work yet. Here's the code:

LinkButton lblOptions = new LinkButton();
lblOptions.CommandName = "Edit";
lblOptions.CausesValidation = false;
lblOptions.ID = "lblOptions" + id;
lblOptions.Text = String.Format("<span style='margin-left:10px;'></
span>{0} other options", total);
lblOptions.Style.Add(HtmlTextWriterStyle.Color, "black");
lblOptions.Style.Add(HtmlTextWriterStyle.FontWeigh t, "bold");
lblOptions.Style.Add(HtmlTextWriterStyle.FontSize, "7pt");

row.Cells[3].Controls.Add(lblOptions);

Pressing the link doesn't put the row in Edit mode!
Any idea?
Jun 27 '08 #4
ata
On Jun 6, 9:29 pm, a...@mailinator.com wrote:
On Jun 6, 8:43 pm, "Riki" <r...@dontnagme.comwrote:
Just make sure that your linkbutton has the property CommandName="Edit".
--
Riki
<a...@mailinator.comwrote in message
news:bc**********************************@e53g2000 hsa.googlegroups.com...
Hi folks,
I've got a LinkButton that's being added to the GridView under certain
circumstances, conditionally.
Whenever the link is clicked, I would like to put the row (that
contains the link) in edit mode.
Please note that I'm trying to do this dynamically, in the run-time.
Any help would be highly appreciated,
Thanks
Jack

Well, I did so, but it doesn't work yet. Here's the code:

LinkButton lblOptions = new LinkButton();
lblOptions.CommandName = "Edit";
lblOptions.CausesValidation = false;
lblOptions.ID = "lblOptions" + id;
lblOptions.Text = String.Format("<span style='margin-left:10px;'></
span>{0} other options", total);
lblOptions.Style.Add(HtmlTextWriterStyle.Color, "black");
lblOptions.Style.Add(HtmlTextWriterStyle.FontWeigh t, "bold");
lblOptions.Style.Add(HtmlTextWriterStyle.FontSize, "7pt");

row.Cells[3].Controls.Add(lblOptions);

Pressing the link doesn't put the row in Edit mode!
Any idea?
WowI Actually find the problem. The link is created based
e.Row.DataItem, in the RowCreated event handler.
However, I've just noticed that when the link button is pressed, the
RowCreated function gets called,
but this time, e.Row.DataItem is null!!!!!!

How this can be possible?
Jun 27 '08 #5

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

Similar topics

1
by: John A Grandy | last post by:
I'm not using SqlDataSource or ObjectDataSource. I'm handling events , similar to approach commonly used in 1.1. DataGrid. My question is : How do I configure a GridView's edit mode row format ?...
1
by: MasterChief | last post by:
Is it possible to select an item on a gridview by clicking on it and then being able to click a link for example that says EditOrder in a treeview and have the EditOrder page open up viewing what...
3
by: misiek | last post by:
Hi all. I have following problem: 1. In my web page I have a GridView control, which does not have a DataSourceId set in designer. 2. When user presses Start button then I create...
4
by: | last post by:
I wanted better control over the display of the command buttons, so I created Template columns for each command. (Otherwise the GridView was putting extras spacing around the images and such.) ...
2
by: luisxx | last post by:
WinSrv2003 SP1 IIS 6.0 ASP.NET C#, 2.0 SQL 2005 All on same machine Hello everyone! I have a method in ASP.NET 2.0 that I can't seem to get right, Gridview1_rowcommand.
2
by: Gerhard | last post by:
How can I set a row in a gridview programatically to edit mode (rather than having to have the user click the edit row command), so the fields can be edited and the Update and Cancel buttons...
3
by: cpnet | last post by:
I have a GridView which I'm populating from an ObjectDataSource (give the GridView a DataTable). The GridView will have about 20 rows, and only one editable column. The editable column consists...
1
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID"...
3
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a gridview that uses a sqldatasource. The rows of the gridview are editable. When the gridview is in edit mode, one of the columns is a dropdown. In testing the editing, I deleted the...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.