Problème au triage d'un gridView
Situation :
J'ai un gridView qui se peuple dans CreateFormat(), appelée dans le Page_Load.
Dans CreateFormat, j'appelle Header_Change(), qui sert à ajouter des contrôles Label dans l'en-tête de 4 colonnes du gridView.
J'ai un événement OnSorted pour le gridView qui rappelle CreateFormat() pour recréer le gridView.
Problème :
Lorsque je tri m'importe quel colonne du gridView, les contrôles Label précédemment placés dans l'en-tête des colonnes, disparaissent.
Pourtant, en faisant des test, j'ai pu voir qu'il y avait toujours 2 contrôles dans l'en-tête, mais il n'y a que l'hyperlien, par défaut lorsque nous utilisons AllowSorting, de visible.
Voici mon gridView :
Code:
1 2 3 4 5
| <asp:GridView
ID="ux_DataFormat" CssClass="BorderStyle" runat="server"
DataSourceID="ux_srcFormat" AllowSorting="true" AutoGenerateColumns="False"
DataKeyNames="" CellPadding="3" Width="80%"
onRowCommand="ux_DataFormat_RowCommand" OnSorted="ux_DataFormat_Sorted"> |
Voici mon code dans Page_Load :
Code:
1 2 3 4 5 6 7 8 9 10 11
| protected void Page_Load(object sender, EventArgs e)
{
InitConnection("LassondeDev");
myConnexionString = myConn.ConnectionString;
if (String.IsNullOrEmpty(Convert.ToString(ViewState["systemeUnite"])))
{
ViewState["systemeUnite"] = "International";
CreateFormat();
}
} |
Voici mon code dans CreateFormat :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| private void CreateFormat()
{
string sCritere = FiltreCritere();
string sQuery = "";
if (Convert.ToString(ViewState["systemeUnite"]) == "International")
{
sQuery = "...";
}
else
{
sQuery = "...";
}
ux_srcFormat.ConnectionString = myConn.ConnectionString;
ux_srcFormat.SelectCommand = sQuery;
ux_DataFormat.DataBind();
BoutonSystem_Change();
Header_Change();
} |
Voici mon code lors du triage :
Code:
1 2 3 4
| protected void ux_DataFormat_Sorted(object sender, EventArgs e)
{
CreateFormat();
} |
Merci d'avance pour vos suggestions