Whith highlighting/selecting a row functionality I cannot edit the text boxes after clicking the edit command

The gridview row gets highlighted when hovering the pointer or clicking on a row. However, the tooltip for the edit/cancel/update buttons are not shown and

when I click the edit button, the textbox for each field does not show a cursor so I can't edit.

The code below shows the javascript for the mouse styles, asp for the edit template field and c# code.

If I don't use the highlighting row functionality, i can edit the fields as per normal. Does anyone else come across this?

<script language="javascript" type="text/javascript">
var oldgridSelectedColor;
function setMouseOverColor(element)
{
   oldgridSelectedColor = element.style.backgroundColor;
   element.style.backgroundColor= 'lightblue';
    element.style.cursor='hand';
}

function setMouseOutColor(element)
{
    element.style.backgroundColor=oldgridSelectedColor;
    element.style.textDecoration='none';
}
</script>
 <asp:templatefield ShowHeader="False">
  <edititemtemplate>
    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="True"
      ValidationGroup="UpdateToolValidation" CommandName="Update"
      ImageUrl="~/Images/Update.gif" Text="Update" />
    <asp:ImageButton ID="ImageButton2" runat="server" CausesValidation="False"
      CommandName="Cancel" ImageUrl="~/Images/Cancel.gif" Text="Cancel" />
  </edititemtemplate>
  <itemtemplate>
    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False"
      CommandName="Edit" ImageUrl="~/Images/Edit.gif" Text="Edit" />
  </itemtemplate>
</asp:templatefield>          
    protected void ToolGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = "this.style.cursor='hand';";
            e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
            e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.ToolGridView, "Select$" + e.Row.RowIndex);

        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
            e.Row.Attributes["onmouseout"] = "javascript:setMouseOutColor(this);";
            e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.ToolGridView, "Select$" + e.Row.RowIndex);
        }
    }
 
0
InsanePaul
11/3/2007 3:42:23 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

4 Replies
822 Views

Similar Articles

[PageSpeed] 42

Surely someone has had this same problem!! Can't anybody help?
0
InsanePaul
11/4/2007 5:16:38 PM

Hi InsanePaul ,

You can use cancelBubble to cancel bubbling for an event so it will not affect subsequent events.

The Text attribute of ImageButton could not always show tooltip , so you can try to use title attribute instead.

See my sample:

 

1    if (e.Row.RowType == DataControlRowType.DataRow)
2                {
3                    if (e.Row.RowState == DataControlRowState.Normal)
4                    {
5                        ImageButton img = (ImageButton)e.Row.Cells[0].Controls[1];//retrieve your select command button , you maybe have to change index of cells and controls
6                        img.Attributes.Add("title","tooltip");
7                    }
8                    if (e.Row.RowState == (DataControlRowState.Selected | DataControlRowState.Edit))
9                    {
10                       TextBox box = (TextBox)e.Row.Cells[1].Controls[0];//retrieve your textbox in edit mode, you maybe have to change index of cells and controls
11                       
12   
13                       box.Attributes.Add("onclick", " if(window.event) {window.event.cancelBubble = true;}else{ event.cancelBubble = true; }");
14   
15                   }
16                   e.Row.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
17                   e.Row.Attributes["onmouseout"] = "javascript:setMouseOutColor(this);";
18                   e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
19               }
 
Sincerely,
Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
Samu
11/7/2007 6:30:07 AM

Hi InsanePaul,

try to use RowEditing event in GridView like below

 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
 {
        grid_GridView1.EditIndex = e.NewEditIndex;
        //Bind the data here
  }

Hope this helps you 


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
11/7/2007 7:02:34 PM

I answered my own question in this link:

http://forums.asp.net/t/1178293.aspx

0
InsanePaul
6/2/2008 3:09:38 PM
Reply:

Similar Artilces:

Return in a Edit Item Template text box to cause the Edit Command button to click in a DataGrid
Hello Everyone I have a DataGrid with ItemTemplates.  What the client wants is to be able to hit return in the edit item template's text box, and as a result have the Edit Command Save button clicked. Doing a search I came across several discussions of this topic that indicated that one could do this using JavaScript, but I'm unclear about how to go about this; I'm guessing that I can trap the key press in the box and cause a postback if it's the return key but don't know what event I'm looking for. Suggestions?   Thanks in advance! I am assuming that there's only one save b...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

if I do custom editable datagrid and I have boundcolumns and on edit command they become textboxes how can I access data in text boxes?
if I do custom editable datagrid and I have boundcolumns and on edit command they become textboxes how can I access data in text boxes? I tryed to access by cell number it always empty.... I think I have to find that textbox control but I didn't declare it since bound columns becomes textboxes(in edit mode). So how can I get Data from the textbox? Thanks in advance If your first column (column 0) is one of those BoundColumns, you can get the value of the edit TextBox in the Update event by using: CType(e.Item.Cells(0).Controls(0), TextBox).Text Hope that helps! Datagrid Girl...

Allow editing of all rows simultaniously (without having to click edit/update for each row)?
I have an application where the user will be presented with perhaps 20 rows.  1 field of each row (the score) will need to be updated by the user.   Now with a gridview they would click on the first row's EDIT button then make the change for the Score field and then click update. Having to do this ~20 times would be somewhat annoying for the user :)  Is there any way I can get an Excel like behavior where the user can just click on the first row's Score field then enter the integer score and hit tab or down arrow or something and drop down to the next one and keep ...

Dynamically add text boxes on row select in GridView,edit them and update into excel file
Hi frens, Can I load textboxes dynamically based on the gridview row count on row select command..display the values of the row..in those textboxes..modify them..and update them into excel file..thing is I am loading thr gridview with an uploaded excel file data.And also I need to add a new row to excel row..from this form...if I click add new row..button I should be able to generate textboxes and add some data..and save them into excel file... main prob is I could not hold the data in text changes(edit)...persist the dynamic controls..  'Function for connection String Function ...

FF doesn't recognize rich text edit boxes as edit boxes
I've noticed that whenever a message board site uses a rich text editor FF does not recognize it as an edit box. Specifically, Ctl-Lft/Rht does not move the cursor word by word, and there is no context menu for Selected text. (One such site is investorvillage.com, but you'd have to register and then enable rich text editing to see the problem.) Is this something the sites can overcome by relabeling the text box, or does something within FF need to be changed? Thanks, p. -- Using FF 1.5.0.6 on Win XP sp2 Paul_B wrote: > I've noticed that whenever a message boar...

superreview granted: [Bug 393711] have to click on the text of folder name in the folder pane instead of anywhere in the row to select mail folder (edit)
Scott MacGregor <mscott@mozilla.org> has granted David Bienvenu <bienvenu@nventure.com>'s request for superreview: Bug 393711: have to click on the text of folder name in the folder pane instead of anywhere in the row to select mail folder (edit) https://bugzilla.mozilla.org/show_bug.cgi?id=393711 Attachment 284327: Trivial fix https://bugzilla.mozilla.org/attachment.cgi?id=284327&action=edit ...

superreview requested: [Bug 393711] have to click on the text of folder name in the folder pane instead of anywhere in the row to select mail folder (edit)
David Bienvenu <bienvenu@nventure.com> has asked Scott MacGregor <mscott@mozilla.org> for superreview: Bug 393711: have to click on the text of folder name in the folder pane instead of anywhere in the row to select mail folder (edit) https://bugzilla.mozilla.org/show_bug.cgi?id=393711 Attachment 284327: Trivial fix https://bugzilla.mozilla.org/attachment.cgi?id=284327&action=edit ...

How to identify when the text in a text box is edited by the user in VB.NET 2003?
Hi, My current scenario is as follows: I have a dropdownlist which has autopostback enabled. Every time the dropdownlist index is changed, I have a textbox which gets populated with the dropdownlist selecteditem text and the textbox is editable by the user. My requirement is:  Until the user doesn't change the text in the textbox, the textbox will keep on getting populated with the dropdownlist selected item text. But, when the user changes the text in the textbox, any change in the dropdownlist selected index shouldn't change the textbox value. In other words, t...

how to disable editing for some of the value in the gridview when edit function is clicked
hi, could anyone tell me how to disable the values for the gridview. Hiyou can convert it to a template field (ie the column thta you want people to not change)then you can change the textbox to a label control in the edititem templated field.Does that make sense?example below... <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource2" Style="position: relative"> <Columns> <asp:CommandField ShowEditButton="True" /> <asp:BoundField Da...

Calling the Edit command instead of clicking the Edit button
Hi, Can I have a datagrid that can click any where in the row to call the Edit Command instead of clicking the Edit Button? Cheers. PLLMS Hi, I wrote a receipt with similar subject in the Cookbook, where you can set the EditItemIndex instead of SelectedIndex as shown in the receipt: Implementing Support for DoubleClicks in a DataGrid Regards Thanks, Colt. My code can now call the Edit Command where ever i click in a row. But i have another question. I have a number of columns on my datagrid. Am I able to get the column (cell) number on which User clicks...

edit in formview(show text in fckeditor after click on edit)
Hi I have a formview with this code.I want to when i click on edit button,see the text in fckeditor for editing.but when i i click on edit  <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1"> <EditItemTemplate> <FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server" Value='<%#bind("FPdes") %>' BasePath="~/FCKeditor/" ToolbarSet="Basic"> </FCKeditorV2:FCKeditor> ...

Size of edit text box when datagrid is in edit mode
I have a datagrid that allows me to put it in edit mode by clicking on the edit button. The editing feature works fine but my problem has to do with the size of the text boxes placed in the grid when it is in edit mode. The text boxes are much larger (width wise) than they need to be. At most I would need to enter a 3 digit number in them but they are big enough to enter a 10-15 digit number. Is there a way I can control the width of the textbox that appears when the datagrid is placed into edit mode? Thanks, David Hi, You can do this by setting the column property of ...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Web resources about - Whith highlighting/selecting a row functionality I cannot edit the text boxes after clicking the edit command - asp.net.presentation-controls

Resources last updated: 12/3/2015 6:56:40 AM