how to delete the selected row in grid view on single mouse click
-
hiiiiiiiii i have a situation where i have to select a row in gridview on single mouse click and when i click the delete button the selected row should be deleted. on double click only the selected row values should be loaded into the asp controls.for the double click i had written the code in row databound as e.Row.Attributes["ondblclick"] = (ClientScript.GetPostBackClientHyperlink(this.gv1_Country, "SELECT$" + e.Row.RowIndex)); and by this i stopped the single mouse click to the datagrid. when coming to single mouse click i had taken a hiddenfeild value and i want to assign the selected row primary key to that hidenfeild value. for that i had written the code in row databound as e.Row.Attributes.Add("onclick", "document.getElementById('hiddenfeildid').value=this.rowIndex"); and now the selected row index value is not coming into the hiddenfeild value..... i hope all u understood my problem... anyone kindly help me............. Thanks in Advance.... VISHNU
-
hiiiiiiiii i have a situation where i have to select a row in gridview on single mouse click and when i click the delete button the selected row should be deleted. on double click only the selected row values should be loaded into the asp controls.for the double click i had written the code in row databound as e.Row.Attributes["ondblclick"] = (ClientScript.GetPostBackClientHyperlink(this.gv1_Country, "SELECT$" + e.Row.RowIndex)); and by this i stopped the single mouse click to the datagrid. when coming to single mouse click i had taken a hiddenfeild value and i want to assign the selected row primary key to that hidenfeild value. for that i had written the code in row databound as e.Row.Attributes.Add("onclick", "document.getElementById('hiddenfeildid').value=this.rowIndex"); and now the selected row index value is not coming into the hiddenfeild value..... i hope all u understood my problem... anyone kindly help me............. Thanks in Advance.... VISHNU
vishnukamath wrote:
e.Row.Attributes.Add("onclick", "document.getElementById('hiddenfeildid').value=this.rowIndex");
Are you sure this line is correct from Javascript prospective? It might be that the hidden field used is a server field (to use it in code behind) and so the actual id of the field when page renders is not just 'hiddenfield'. 2 things: 1. try an alert box first. Popup the alert(this.rowindex); 2. Do a view source and check what is the ID of the hidden field. If step 1 works above as expected then replace the ID with what you find in viewsource.
-
hiiiiiiiii i have a situation where i have to select a row in gridview on single mouse click and when i click the delete button the selected row should be deleted. on double click only the selected row values should be loaded into the asp controls.for the double click i had written the code in row databound as e.Row.Attributes["ondblclick"] = (ClientScript.GetPostBackClientHyperlink(this.gv1_Country, "SELECT$" + e.Row.RowIndex)); and by this i stopped the single mouse click to the datagrid. when coming to single mouse click i had taken a hiddenfeild value and i want to assign the selected row primary key to that hidenfeild value. for that i had written the code in row databound as e.Row.Attributes.Add("onclick", "document.getElementById('hiddenfeildid').value=this.rowIndex"); and now the selected row index value is not coming into the hiddenfeild value..... i hope all u understood my problem... anyone kindly help me............. Thanks in Advance.... VISHNU
Hi Vishnu, Please take 2 seperate button fields i.e. 1)Edit button 2)Delete Button. I think it'll be easy for u to code for actions.