473,385 Members | 1,445 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,385 software developers and data experts.

GridView change mode to Edit

149 100+
Hi,

I am creating a WYSIWIG CMS and when the user clicks on a linkbutton in an update panel, I would like to change the mode of the gridview to edit.

I am confused about how to make a javascript event initialise an asp.net method? And also how to create a method that will change the rows in my gridview to editable when selected?

Any help would be appreciated.
Jul 24 '07 #1
3 6791
kenobewan
4,871 Expert 4TB
JS can be used in script by using attributes.add. Here is an article that may answer your gridview questions:
In-Depth look at the GridView Control
Jul 24 '07 #2
rsdev
149 100+
Thanks Kenobewan,

I've managed to add the JS to my gridview cells, but making them editable is tricky must have read hundreds of posts and tuts but no luck?

here my code so far;

Expand|Select|Wrap|Line Numbers
  1.  protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
  2.     {
  3.         if (e.Row.RowType == DataControlRowType.DataRow)
  4.         {
  5.             for (int columnIndex = 1; columnIndex < e.Row.Cells.Count; columnIndex++)
  6.             {
  7.                 string name = e.Row.UniqueID.Replace("_", "$");
  8.                 // Add this javascript to the onclick Attribute of the cell
  9.                 e.Row.Cells[columnIndex].Attributes.Add("onclick", "javascript:__doPostBack('" + name + "','Select$" + e.Row.DataItem.ToString() + "')");
  10.                 // Add a cursor style to the cells
  11.                 e.Row.Cells[columnIndex].Attributes["style"] += "cursor:pointer;cursor:hand;";
  12.             }
  13.         }
  14.     }
  15.     protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
  16.     {
  17.  
  18.     }
I want to invoke the edit mode in SelectedIndexChange but can't work it out. I can't use GridRowEventArgs, so no luck with NewEditIndex.

I've also tried this post http://www.codeproject.com/aspnet/EditGridviewCells.asp.

But I need to use BoundFields so this isn't working. Any ideas to point me in the right direction?
Jul 24 '07 #3
rsdev
149 100+
I've managed to hash something together using isEditMode = true and hidden textBox/Labels etc. Unfortunately it doesn't isolate the editmode to one cell but it'll have do.

Cheers
Jul 24 '07 #4

Sign in to post your reply or Sign up for a free account.

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 ?...
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.) ...
1
by: joechipubik | last post by:
I have a GridView in a FormView that has as its datasource a DataTable that is stored in the session cache. When I first load the page the GridView is displayed correctly, but on subsequent loads...
0
by: tim.cavins | last post by:
I am trying a GridView for the first time and it seems to be something that should be EXTREMELY simple. I cannot get the Update or Cancel when trying to edit a row to work. When I click on the...
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"...
1
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have...
5
by: kageyone | last post by:
I am trying to use the .net 2.0 gridview control where I programmatically set the datasource to an xml file read into a dataset. I am able to use the commandfield for the edit button and it puts me...
3
by: pvong | last post by:
VB.NET How do you change a gridview from Update mode to normal mode? I'm usually dealing for Formviews and there is a ChangeMode option but I don't see one for Gridviews.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.