Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET ADO.NET
I want to take grid view on editmode for this i have to important things as i mention below
 
=>Add attribute doubleclick:
 
e.Row.Attributes.Add("ondblclick", "Javascript:__doPostBack('myDblClick','" + e.Row.RowIndex + "');");
 
=>And for edit a gridview
protected void grdvmovies_RowEditing(object sender, GridViewEditEventArgs e)
 
{
 
grv1.EditIndex = e.NewEditIndex;
 
}
 
But how i can combine together mean i want to add a Gridview edit event handler on row double click attribute but i am unable to add on it.
Posted 1-Jan-13 22:06pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

As your requirement demands, I don't think there is any inbuilt functionality to achieve it. However, you can play with javascript and create your custom solution. Following steps willl give you an idea. Modify the code and give it a try. Do not use auto update and addition of records.
 
1) Add a row below or above your gridview with the editable fields (textboxes and other controls) with a lable (lblSelectedRecord) to show Record ID and two buttons (btnUpdate & btnCancel)
2) Add Button(which will not be displayed on the page) on your aspx page as:
<asp:button runat="server" id="btnHDN" style="display:none" onclick="btnHDN_Click" xmlns:asp="#unknown" />
3) Add a invisible label(lblRecordID) with text as record ID at 0th column of your gridview and add this code inside the "OnRowDataBound" event.
Label lbl = new Label();
lbl = (Label)e.Row.FindControl("lblRecordID");
e.Row.Attributes.Add("ondblclick","selectRow('"+lbl.Text.Trim()+"')");
4) Add javascript in your aspx page:
function selectRow(rowId)
{
document.getElementById("lblSelectedRecord").value = rowId;
__doPostBack("btnHDN","");
}
 
In your code-behind write:
 
protected void btnHDN_Click(object sender, EventArgs e)
{
string _recordId = lblSelectedRecord.Text.Trim(); 
//your code to fill the details of the selected record
}
 
5) Write update functionality in btnUpdate_Click event and cancelling functionality in btnCancel_Click event
6) Re-bind your gridview.
7) Make adjustments to the code as it is not tested. It is just randomly written.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
On your double click event get the row id and in that event set the
 
grv1.EditIndex = e.NewEditIndex;
  Permalink  
Comments
maheshbisht at 2-Jan-13 6:57am
   
Hello Sir did u ever try this on adding attribute, it's useless.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 2 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100