[ASP][NET1.1]Probleme avec la fonction DataBinder.Eval()
Slt,
J'ai un probleme avec la fonction DataBinder.Eval() dans ma page asp.
Dans mon code behdin, je crée et remplie une dataTable comme ceci:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
DataTable myDt = new DataTable("Infos");
myDt.Columns.Add(new DataColumn("FileName", typeof(String)));
myDt.Columns.Add(new DataColumn("Date", typeof(DateTime)));
myDt.Columns.Add(new DataColumn("Area", typeof(String)));
myDt.Columns.Add(new DataColumn("NumberOfProjects", typeof(Int32)));
myDt.Columns.Add(new DataColumn("NumberOfDocuments", typeof(Int32)));
myDt.Columns.Add(new DataColumn("TypeOfPCR", typeof(String)));
DataRow row = myDt.NewRow();
// Fill each column
row["FileName"] = "Test_nom_de_fichier";
row["Date"] = DateTime.Now;
row["NumberOfProjects"] = "8";
row["NumberOfDocuments"] = "10";
row["Area"] = "Collaboration";
row["TypeofPCR"] = PCR_TYPE;
// Add the row to the DataTable
myDt.Rows.Add(row);
DataView myDv = new DataView(myDt);
MyDataGrid.DataSource = myDv;
MyDataGrid.DataBind(); |
Maintenant dans mon fichier ASP, en plus des 6 colonnes de ma DataTable, je lui ajoute une colonne avec une textBox par ligne. Pour chacune de ces textBox, je souhaiterais leur affecter comme ID la valeur de row["FileName"] = "Test_nom_de_fichier";, cest a dire "Test_nom_de_fichier".
Pour cela j'ai testé ceci:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
<asp:DataGrid
id="MyDataGrid"
runat="server"
AutoGenerateColumns="False"
>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox
id='DeleteThisReport_<%# DataBinder.Eval(Container.DataItem, "FileName")%>'
runat="server"
/>
</ItemTemplate>
</asp:TemplateColumn>
<asp:HyperLinkColumn
HeaderText="See detail"
DataNavigateUrlField="FileName"
Text="Detail"
DataNavigateUrlFormatString="~/PCRDetailsPage.aspx?filename={0}"
Target="_new"
/>
<asp:BoundColumn
DataField="Date"
HeaderText="Date"
/>
<asp:BoundColumn
DataField="Area"
HeaderText="Area"
/>
<asp:BoundColumn
DataField="NumberOfProjects"
HeaderText="Nb of project"
/>
<asp:BoundColumn
DataField="NumberOfDocuments"
HeaderText="Nb of file"
/>
<asp:BoundColumn
DataField="TypeOfPCR"
HeaderText="Type"
/>
</Columns>
</asp:DataGrid> |
A l'execution jai cette erreur:
Citation:
'DeleteThisReport_<%# DataBinder.Eval(Container.DataItem, "FileName")%>' is not a valid identifier
Pourquoi cette erreur? j'ai pourtant bien ma colonne qui sàppelle "Filename" dans ma dataTable.
Merci d'avance.
++