Bonjour,
J'ai un gridview et je souhaite mettre des images pour trier certaines colonnes, j'arrive à mettre une image pour trier mais l'image n'est pas cliquable donc ne lance pas le script.
ci-joint mon script sur gridview_rowcreated:
protectedvoid GridView1_RowCreated(object sender, GridViewRowEventArgs e){if ((e.Row != null) && e.Row.RowType == DataControlRowType.Header) {
foreach (TableCell cell in e.Row.Cells) {
if (cell.Controls.Count > 0) {
LinkButton button = cell.Controls[0] asLinkButton;
if (button != null) {
Image image = newImage();
image.ImageUrl = "images/calendrierX.gif";
if (GridView1.SortExpression == button.CommandArgument){
if (GridView1.SortDirection == SortDirection.Ascending)
image.ImageUrl = "images/calendrier1.gif";
else
image.ImageUrl = "images/calendrier2.gif";
} cell.Controls.Add(image);
}
}
}
}
}
<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"DataMember="DefaultView"DataSourceID="XXXXX"CellPadding="2"ForeColor="#333333"GridLines="None"AllowPaging="True"Font-Names="Arial"Font-Size="Small"DataKeyNames="IdX"OnRowDeleting="GridView1_RowDeleting"PageSize="30"BorderColor="#8080FF"BorderWidth="2px"CellSpacing="1"AllowSorting="True"OnRowCreated="GridView1_RowCreated">Merci
fred