我正在使用以下代码。 在.aspx中:
function AccessOnclient() {
debugger;
var grid = $find("<%= dg_InvPat.ClientID %>");
if (grid) {
var MasterTable = grid.get_masterTableView();
var sumtemp = 0;
var Rows = MasterTable.get_dataItems();
for (var i = 0; i < Rows.length; i++) {
var row = Rows[i];
var RadNumericTextBox1 = row.findControl("txt_projInv");
if (RadNumericTextBox1.get_value())
{
sumtemp =sumtemp + RadNumericTextBox1.get_value();
}
}
for (var i = 0; i < Rows.length; i++) {
var row = Rows[i];
var RadNumericTextBox1 = row.findControl("txt_projInv");
var valinv=RadNumericTextBox1.get_value();
var res=Math.round((valinv/sumtemp)*100);
var revpat = MasterTable.get_dataItems()[i].findElement("lbl_revpat");//access the Label control
revpat.innerText = res;
}
document.getElementById("ctl00_MainContent_b1").click();
}
}
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<div id="content">
<table class="table_Style" width="100%">
<tr>
<td style="width: 15%">
<asp:Label ID="Label2" runat="server">Financial Year</asp:Label>
</td>
<td>
<Telerik:RadComboBox AutoPostBack="true" runat="server" ID="ddl_year" Width="200px"
MarkFirstMatch="true" CausesValidation="true" ValidationGroup="List">
</Telerik:RadComboBox>
<asp:Button ID="cmd_go" runat="server" Text="View" CausesValidation="true"
ValidationGroup="btnSubmit"></asp:Button>
<asp:CompareValidator ID="cvyear" runat="server" ErrorMessage="Please Select Financial Year"
ControlToValidate="ddl_year" ValueToCompare="Select" Operator="NotEqual" ValidationGroup="btnSubmit"></asp:CompareValidator>
</td>
</tr>
</table>
<table class="table_Style" width="100%">
<tr>
<td>
<Telerik:RadGrid ID="dg_InvPat" runat="server" AutoGenerateColumns="False" GridLines="None"
HeaderStyle-VerticalAlign="Top" Width="100%" ShowStatusBar="True" AllowPaging="True"
AllowSorting="false" AllowFilteringByColumn="False" PageSize="5">
<GroupingSettings CaseSensitive="false" />
<ExportSettings ExportOnlyData="true" OpenInNewWindow="True" IgnorePaging="true"
FileName="InvPattern">
</ExportSettings>
<MasterTableView CommandItemDisplay="None" CommandItemSettings-ShowRefreshButton="false"
CommandItemSettings-ShowAddNewRecordButton="false">
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<NoRecordsTemplate>
<font color="red">No Records Available</font>
</NoRecordsTemplate>
<Columns>
<Telerik:GridBoundColumn UniqueName="NOTIF1" DataField="NOTIF1" HeaderText="As Per Notification" Visible ="false" >
</Telerik:GridBoundColumn>
<Telerik:GridBoundColumn UniqueName="NOTIF" DataField="NOTIF" HeaderText="As Per Notification">
</Telerik:GridBoundColumn>
<Telerik:GridBoundColumn UniqueName="CAT" DataField="CAT" HeaderText="Pattern Category">
</Telerik:GridBoundColumn>
<Telerik:GridBoundColumn UniqueName="INVESTMENT" DataField="INVESTMENT" HeaderText="Act Investment">
</Telerik:GridBoundColumn>
<Telerik:GridBoundColumn UniqueName="LIMITID" DataField="LIMITID" HeaderText="Limit Id"
Visible="false">
</Telerik:GridBoundColumn>
<Telerik:GridBoundColumn UniqueName="TRUSTPAT1" DataField="TRUSTPAT1" HeaderText="Trust Pattern" Visible="false">
</Telerik:GridBoundColumn>
<Telerik:GridBoundColumn UniqueName="TRUSTPAT" DataField="TRUSTPAT" HeaderText="Trust Pattern">
</Telerik:GridBoundColumn>
<Telerik:GridBoundColumn UniqueName="SHORTAGE" DataField="SHORTAGE" HeaderText="Shortfall/Excess">
</Telerik:GridBoundColumn>
<Telerik:GridTemplateColumn HeaderText="Project Investment">
<ItemTemplate>
<Telerik:RadNumericTextBox ID="txt_projInv" runat="server" EmptyMessage="" IncrementSettings-InterceptMouseWheel="false"
SkinID="RadTextYellow" Type="Number" DataType="System.Int64"
AutoPostBack="false" MaxLength="8" Text='<%# Bind("investment") %>'>
<NumberFormat DecimalDigits="0" GroupSeparator="" />
<ClientEvents OnKeyPress="AccessOnclient" OnValueChanged="AccessOnclient"/>
</Telerik:RadNumericTextBox>
</ItemTemplate>
</Telerik:GridTemplateColumn>
<Telerik:GridTemplateColumn HeaderText="Revised Pattern">
<ItemTemplate>
<asp:Label ID="lbl_revpat" runat="server" Text='<%# Bind("trustpat1") %>'></asp:Label>
</ItemTemplate>
</Telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</Telerik:RadGrid>
</td>
</tr>
<tr id="tr1">
<td colspan="2">
<table width="100%" border="0" >
<tr>
<td align="center">
<br/>
<div id="divgraph1" runat="server" >
<asp:Panel ID="pnlnum" runat="server" Width="100%" Visible="False" style="height:400px">
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</asp:Panel>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblhead" runat="server" Font-Size="10" ForeColor="#000033"
Font-Bold="True"></asp:Label>
</td>
<td align="right">
<asp:Label ID="lbltotal" runat="server" Font-Size="10" ForeColor="#000033"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label Width="100%" ID="lblmess" SkinID="lblErr" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Button id="b1" runat="server" />
</td>
</tr>
<tr>
<td colspan="2">
<Telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Default"
Skin="Sunset" Style="margin-bottom: 0px" />
<Telerik:RadWindowManager ID="RadWindowManager2" ShowContentDuringLoad="false" VisibleStatusbar="false"
ReloadOnShow="true" runat="server" Modal="true">
</Telerik:RadWindowManager>
</td>
</tr>
</table>
</div>
</asp:Content>
.aspx.vb中的:
#Region "Namespaces"
Imports Telerik.Web.UI
Imports System.Data
Imports System.Net
Imports System
Imports System.IO
Imports System.Text
Imports System.Net.Mail
Imports InfoSoftGlobal.InfoSoftGlobal
#End Region
Partial Class iv
Inherits System.Web.UI.Page
#Region "Declarations"
Dim objEntry_ml As ClsPF_BE
Dim objEntry_bll As ClsPF_BLL
Dim ds As DataSet
Dim objCom_ml As Common_ml
Dim objCom_bll As Common_bll
Dim UserSysId As Long
Public UnitID As Integer
Public UnitName As String
Dim strXML As String
#End Region
#Region "PageEvents"
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
AddHandler Master.PageEvent, AddressOf Page_Load
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Master.UnitChange = True Then
Response.Redirect("iv.aspx")
End If
Master.PageHeadingTitle = "Pattern"
If Not Session("UserSysId") Is Nothing Then
UnitID = Session("UnitId")
UnitName = Session("UnitName")
UserSysId = Session("UserSysId")
Else
Response.Redirect("Login.aspx?Status=S")
End If
If Not IsPostBack Then
LoadYear()
End If
lblmess.Text = ""
End Sub
Protected Sub cmd_go_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmd_go.Click
LoadGrid()
Literal1.Text = DrawGraph()
pnlnum.Visible = True
divgraph1.Visible = True
End Sub
Private Sub LoadGrid()
Dim ds As New DataSet
Try
objEntry_ml = New ClsPF_BE
objEntry_bll = New ClsPF_BLL
Dim sReturnMessage As String = ""
objEntry_ml.FinYear_code = ddl_year.SelectedValue
ds = objEntry_bll.bll_Invpattern(objEntry_ml, UserSysId, sReturnMessage)
dg_InvPat.DataSource = ds
dg_InvPat.DataBind()
ds = Nothing
If dg_InvPat.Items.Count > 1 Then
lblmess.Visible = False
divgraph1.Visible = True
Else
lblmess.Text = "No records found for the year" & ddl_year.Text
lblmess.Visible = True
End If
Catch ex As Exception
End Try
End Sub
Sub LoadYear()
objEntry_ml = New ClsPF_BE
objEntry_bll = New ClsPF_BLL
ds = objEntry_bll.fillfinyear(objEntry_ml)
ddl_year.DataSource = ds
If ds.Tables(0).Rows.Count > 0 Then
ddl_year.DataValueField = ds.Tables(0).Columns(0).Caption
ddl_year.DataTextField = ds.Tables(0).Columns(1).Caption
ddl_year.DataBind()
If ddl_year.Items.Count > 0 Then
ddl_year.Items.Insert(0, New RadComboBoxItem("Select", ""))
End If
End If
objEntry_ml = Nothing
objEntry_bll = Nothing
ds = Nothing
End Sub
#End Region
#Region "Functions"
Public Function DrawGraph() As String
Try
Dim ds As DataSet
Dim dv As DataView
Dim dr As DataRowView
Dim sReturnMessage As String = ""
objEntry_ml = New ClsPF_BE
objEntry_bll = New ClsPF_BLL
strXML = "<chart palette='4' pieSliceDepth='30' pieRadius='120' CAPTION='Investment Pattern(In %)' bgcolor='#e5e5e5' outCnvBaseFont='verdana' outCnvBaseFontSize='11' showPercentageValues='1' bgAngle='360' showBorder='1' baseFont='Arial' baseFontSize='11' baseFontColor ='000000'>"
For Each item As GridDataItem In dg_InvPat.Items
Dim txt As Label = DirectCast(item.FindControl("lbl_revpat"), Label)
Dim aa As String = txt.Text
strXML = (strXML & ("<set label='" & (Server.HtmlEncode(item.Cells(4).Text) & ("' value='" & aa & "'/>"))))
Next
strXML = (strXML & "</chart>")
Return FusionCharts.RenderChartHTML("FusionCharts/Charts/Pie3D.swf", "", Server.UrlEncode(strXML.ToString), "Percentage", "500", "350", False)
Catch ex As Exception
divgraph1.Visible = False
lblmess.Text = "You have no rights to view this report"
lblmess.ForeColor = Drawing.Color.Red
lblhead.Text = ""
lbltotal.Text = ""
End Try
End Function
#End Region
Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click
Literal1.Text = DrawGraph()
pnlnum.Visible = True
divgraph1.Visible = True
End Sub
End Class
这里当我在radgrid中的templatecolumn中修改文本框时,相应的值存储在标签(Radgrid的GridTemplateColumn)中。那是用javascript编写的。但是没有显示相应的融合图。当我调试时,不考虑新值(由javascript计算)。只有在网格中绑定的值才会在融合图中绘制。
在DrawGraph()函数中,我使用名为修改模式(GridTemplateColumn)值的标签作为<set label
值。但新的价值不会到来。
例如。如果我在项目投资列中给出600,相应的百分比42将进入修订模式(GridTemplateColumn)。但融合图表没有改变。
如何解决问题?
任何人请帮助我.........
答案 0 :(得分:4)
我建议你去文本框而不是标签
因为文本框是服务器控件而标签有问题总是获取值 就像你使用更新面板一样...... 因此,文本框将是使用
的最佳选择