Wizilling
asked on
gridview and confirmbuttonextender
Hi, I have a gridview and a custom code delete button in my asp.net page.
The delete button fires confirmbuttonextender control when click . This is working fine and I see the dialog box asking whether to continue with delete or not.
What I want to do is , when the delete button is click, The selected row is highlight and then the confirm button extender control to be called.
I tried rowcommand but that fires after.
I am using c# and asp.net .
The delete button fires confirmbuttonextender control when click . This is working fine and I see the dialog box asking whether to continue with delete or not.
What I want to do is , when the delete button is click, The selected row is highlight and then the confirm button extender control to be called.
I tried rowcommand but that fires after.
I am using c# and asp.net .
ASKER
Hi, Nothing happens..
I changed this bit --- e.Row.FindControl("btnSele ct")
the confirm button extender still fires first and the color of the row doesnt change to blue.
I changed this bit --- e.Row.FindControl("btnSele
the confirm button extender still fires first and the color of the row doesnt change to blue.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use javascript to change row color and once you've created your javascript function, you can then attached this to the onclick event of the select button in your gridview (which I guess is your targetcontrolid in your confirmbutton extender) through the RowCreated event of your GridView.
In your Design - Source, add this javascript
<script language ="javascript" type="text/javascript">
var oldColor = '';
var currentRowID;
var currentColor;
var previousRowID;
var previousColor = '';
function ChangeRowColor(rowID)
{
var color = document.getElementById(ro
currentRowID = rowID;
currentColor = color;
if (currentRowID == previousRowID)
return;
if (previousRowID != null) {
//Return previous row to original state
document.getElementById(pr
}
document.getElementById(ro
previousColor = currentColor;
previousRowID = currentRowID;
}
</script>
In your code-behind, do this something like this where btnSelect is the targetcontrolid
private void GridView1_RowCreated(objec
string rowID = String.Empty;
Button btnSelect;
if ((e.Row.RowType == DataControlRowType.DataRow
btnSelect = ((Button)(e.Row.FindContro
rowID = ("row" + e.Row.RowIndex.ToString);
e.Row.Attributes.Add("id",
btnSelect.Attributes.Add("
+ (rowID + ("\'" + ")")))));
}
}
I hope this helps.