i have a simple gridview where i want to display an itemtemplate for edit and delete buttons.
PHP Code:<asp:GridView ID="GridView1" runat="server" Width="500px"
ShowHeader="False" EnableTheming="False"
AutoGenerateColumns="False" AutoGenerateRows="False"
DataKeyNames="id">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="LabelName" runat="server" Text='<%# Eval("name") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<!-- Delete -->
<button type="submit" id="Buttondelete_<%#((GridViewRow)Container).RowIndex %>">
<img src="/images/icons/delete.png" alt="Delete"/>
Delete
</button>
<script type="text/javascript">
// Instantiate the Dialog
YAHOO.namespace("knowledgebase.categories.actionDelete");
function knowledgebase_categories_init() {
// Define various event handlers for Dialog
var handleYes = function() {
alert("You clicked yes!");
this.hide();
};
var handleNo = function() {
this.hide();
};
var OnTrigger = function()
{
this.show();
}
// Instantiate the Dialog
YAHOO.knowledgebase.categories.actionDelete.simpledialog1 =
new YAHOO.widget.SimpleDialog("simpledialog1",
{ width: "300px",
fixedcenter: true,
visible: false,
draggable: false,
close: true,
text: "Do you want to continue?",
icon: YAHOO.widget.SimpleDialog.ICON_HELP,
constraintoviewport: true,
buttons: [ { text:"Yes", handler:handleYes, isDefault:true },
{ text:"No", handler:handleNo } ]
} );
YAHOO.knowledgebase.categories.actionDelete.simpledialog1.setHeader("Are you sure?");
YAHOO.knowledgebase.categories.actionDelete.simpledialog1.render("container");
YAHOO.util.Event.addListener('Buttondelete_<%#((GridViewRow)Container).RowIndex %>', 'click', OnTrigger);
}
YAHOO.util.Event.addListener(window, "load", knowledgebase_categories_init);
</script>
</ItemTemplate>
</asp:TemplateField>
but <%#((GridViewRow)Container).RowIndex %> renders to an empty string.
I also can't seem to get the client id
((GridViewRow)Container).FindControl("somcontrolid").ClientID
also yields an empty string.
i hate to write javascript code in the .cs file.
and avoid avoid looping as in the link below.
http://www.sitepoint.com/forums/showthread.php?t=533444
-lm







Bookmarks