Вызов функции во всех элементов таблицы
Всем Привет ,
Я попытался вызвать функцию в каждом элементе в элементах DataList, но она работает только в первом элементе
Это мой функциональный код
private void gauges() { int i = 5; str.Append(@"google.charts.load('current', {'packages':['gauge']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var value="); str.Append(""+i +";"); str.Append("var valueph ="); str.Append("" + i + ";"); str.Append("var data = google.visualization.arrayToDataTable([['Label', 'Value'],['Temp', Number(value)]]);"); str.Append("var dataph = google.visualization.arrayToDataTable([['Label', 'Value'],['p.H', Number(valueph)]]);"); str.Append("var options = { width: 100, height: 100,redFrom: 50, redTo: 125, greenFrom: 0, greenTo: 60,yellowFrom: -55, yellowTo: 20,minorTicks: 3.5,max: 125,min: -55};"); str.Append(" var optionsph = {width: 100, height: 100,redFrom: 9, redTo: 14,greenFrom: 6.5, greenTo: 9,yellowFrom: 0, yellowTo: 6.5, minorTicks: 3.5, max: 14, min: 0 };"); str.Append("var chart = new google.visualization.Gauge(document.getElementById('chart_div'));"); str.Append("chart.draw(data, options);"); str.Append("var chart2 = new google.visualization.Gauge(document.getElementById('chart_div2'));"); str.Append("chart2.draw(dataph, optionsph);}"); str.Append(""); lt.Text = str.ToString().Replace('*', '"'); }
а вот внутри пункт таблицы
protected void DataList3_ItemDataBound(object sender, DataListItemEventArgs e) { foreach (DataListItem dli in DataList3.Items) { gauges(); } }
<asp:DataList ID="DataList3" runat="server" DataSourceID="SqlDataSource3" RepeatColumns="2" RepeatDirection="Horizontal" DataKeyNames="DevId" OnItemDataBound="DataList3_ItemDataBound" BackColor="#CC33FF" BorderColor="#E7E7FF" BorderStyle="Groove" BorderWidth="2px" CellPadding="3" GridLines="Horizontal" > <AlternatingItemStyle BackColor="#F7F7F7" /> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <ItemStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <ItemTemplate> <table style="width:100%;"> <tr> <td > <div> <asp:Literal ID="lt" runat="server"></asp:Literal> </div> <div id="chart_div" style="width: 50px; height: 50px; " ></div> </td> <td> </td> <td> <div> <asp:Literal ID="Literal1" runat="server"></asp:Literal> </div> <div id="chart_div2" style="width: 50px; height: 50px;" ></div> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource2"> <EditItemTemplate> Reading: <asp:TextBox ID="ReadingTextBox" runat="server" Text='<%# Bind("Reading") %>' /> <br /> DateTRead: <asp:TextBox ID="DateTReadTextBox" runat="server" Text='<%# Bind("DateTRead") %>' /> <br /> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </EditItemTemplate> <InsertItemTemplate> Reading: <asp:TextBox ID="ReadingTextBox" runat="server" Text='<%# Bind("Reading") %>' /> <br /> DateTRead: <asp:TextBox ID="DateTReadTextBox" runat="server" Text='<%# Bind("DateTRead") %>' /> <br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" /> <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </InsertItemTemplate> <ItemTemplate> <table style="width:100%;"> <tr> <td colspan="3"> </td> </tr> <tr> <td class="auto-style1"> <asp:Label ID="Label7" runat="server" Font-Bold="True" ForeColor="#CC33FF" Text="Last Temp Read :"></asp:Label> </td> <td> </td> <td> </td> </tr> <tr> <td class="auto-style1" colspan="3"> <asp:Label ID="DateTReadLabel" runat="server" Text='<%# Bind("DateTRead") %>' /> </td> </tr> <tr> <td class="auto-style1" colspan="3"> <asp:Label ID="DateTReadLabel5" runat="server" Text='<%# Bind("Reading") %>' /> </td> </tr> </table> </ItemTemplate> </asp:FormView> </td> <td> </td> <td> <asp:FormView ID="FormView2" runat="server" DataSourceID="SqlDataPh"> <EditItemTemplate> Reading: <asp:TextBox ID="ReadingTextBox" runat="server" Text='<%# Bind("Reading") %>' /> <br /> DateTRead: <asp:TextBox ID="DateTReadTextBox" runat="server" Text='<%# Bind("DateTRead") %>' /> <br /> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </EditItemTemplate> <InsertItemTemplate> Reading: <asp:TextBox ID="ReadingTextBox0" runat="server" Text='<%# Bind("Reading") %>' /> <br /> DateTRead: <asp:TextBox ID="DateTReadTextBox0" runat="server" Text='<%# Bind("DateTRead") %>' /> <br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" /> <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </InsertItemTemplate> <ItemTemplate> <table style="width:100%;"> <tr> <td colspan="3"> </td> </tr> <tr> <td class="auto-style1"> <asp:Label ID="Label9" runat="server" Font-Bold="True" ForeColor="#CC33FF" Text="Last pH Read :"></asp:Label> </td> <td> </td> <td> </td> </tr> <tr> <td class="auto-style1" colspan="3"> <asp:Label ID="DateTReadLabel" runat="server" Text='<%# Bind("DateTRead") %>' /> </td> </tr> <tr> <td class="auto-style1" colspan="3"> <asp:Label ID="DateTReadLabel0" runat="server" Text='<%# Bind("Reading") %>' /> </td> </tr> </table> </ItemTemplate> </asp:FormView> </td> </tr> </table> </ItemTemplate> <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> </asp:DataList>
Что я уже пробовал:
.....................................................................