2010年10月26日 星期二

ReportViewer在IIS7執行出現rsClientController未被定義

ReportViewer在IIS7執行出現rsClientController未被定義!
參考網址:http://casear.blogspot.com/2008/10/rdlc-in-iis7.html

1.在站台設定中的
Handler Mapping新增Managed Handler
2.Request Path輸入Reserved.ReportViewerWebControl.axd
3.Type選擇Microsoft.Reporting.......
4.Name輸入Reserved.ReportViewerWebControl.axd

2010年10月19日 星期二

Crystal Report小數點後面不顯示0














格式化欄位 --> 數位 -->自訂 -->數字 --> 小數位數(D) --> 編輯公式
公式如下:

if Right(ToText({報表欄位},4),4) ="0000" then 0
else if Right(ToText({報表欄位},4),3) ="000" then 1
else if Right(ToText({報表欄位},4),2) ="00" then 2
else if Right(ToText({報表欄位},4),1) ="0" then 3
else 4

2010年9月17日 星期五

判斷中文字

'判斷字串中的中文字數和中文字
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim ex As New Regex("[一-龥]")
Dim isMatched As Boolean = ex.IsMatch(TextBox4.Text)
Dim m As MatchCollection = ex.Matches(TextBox4.Text)
Dim chi As String = ""
Dim chiCount As Int16 = 0
For i As Int16 = 0 To m.Count - 1
chi &= m.Item(i).Value
chiCount = chiCount + 1
Next
MessageBox.Show("中文字數:" & chiCount & ",中文字:" & chi)
End Sub

'顯示字元碼
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
MessageBox.Show(AscW(TextBox1.Text))
End Sub

2010年5月29日 星期六

javascript取checkboxlist值

=====網頁======
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Javascript_Checkbox.aspx.cs" Inherits="Javascript_Checkbox" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Javascript Selectted Item From CheckBoxList</title>

<script type="text/javascript">
function Get_Selected_Value()
{
var ControlRef = document.getElementById('<%= CheckBoxList1.ClientID %>');
var CheckBoxListArray = ControlRef.getElementsByTagName('input');
var spanArray=ControlRef.getElementsByTagName('span');
var checkedValues = '';
var nIndex=0;
var sValue='';

for (var i=0; i<CheckBoxListArray.length; i++)
{
var checkBoxRef = CheckBoxListArray[i];

if ( checkBoxRef.checked == true )
{
var labelArray = checkBoxRef.parentNode.getElementsByTagName('label');


if ( labelArray.length > 0 )
{
if ( checkedValues.length > 0 )
{
checkedValues += ', ';
nIndex += ', ';
sValue += ', ';
}
checkedValues += labelArray[0].innerHTML;
nIndex +=i;
sValue +=spanArray[i].alt;
}
}
}
document.getElementById('<%= lbl_SelectedValue.ClientID %>').innerHTML='<b>Selected Value:</b> '+ sValue;
document.getElementById('<%= lbl_SelectedText.ClientID %>').innerHTML='<b>Selected Text:</b> '+checkedValues;
document.getElementById('<%= lbl_SelectedIndex.ClientID %>').innerHTML='<b>Selected Index:</b> '+nIndex;
}
</script>

</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList ID="CheckBoxList1" runat="server" onclick="Get_Selected_Value();" OnDataBound="CheckBoxList1_DataBound">
</asp:CheckBoxList>
<hr />
<label id="lbl_SelectedValue" runat="server"></label><br />
<label id="lbl_SelectedText" runat="server"></label><br />
<label id="lbl_SelectedIndex" runat="server"></label>
</div>
</form>
</body>
</html>

=====程式碼======
using System;
using System.Data;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class Javascript_Checkbox : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString = ConfigurationManager.ConnectionStrings["TestConnection"].ConnectionString;
DataTable dt = new DataTable();
SqlConnection conn = new SqlConnection(connectionString);
using (conn)
{
SqlDataAdapter ad = new SqlDataAdapter(
"SELECT ID,Title from Article", conn);
ad.Fill(dt);
}
CheckBoxList1.DataSource = dt;
CheckBoxList1.DataTextField = "Title";
CheckBoxList1.DataValueField = "ID";
CheckBoxList1.DataBind();
}

protected void CheckBoxList1_DataBound(object sender, EventArgs e)
{
CheckBoxList chkList = (CheckBoxList)(sender);
foreach (ListItem item in chkList.Items)
item.Attributes.Add("alt", item.Value);
}
}

2010年4月20日 星期二

由ItemTemplate中的Button取得GridView的SelectedRow

方法一:
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" CommandName ="111" />
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button2" runat="server" Text="Button" CommandName ="222" />
</ItemTemplate>
</asp:TemplateField>

Protected Sub gv_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv.RowCommand

Dim index As Integer = DirectCast(DirectCast(e.CommandSource, Button).NamingContainer, GridViewRow).RowIndex

If e.CommandName = "111" Then
Response.Write(gv.Rows(index).Cells(1).Text)
End If

If e.CommandName = "222" Then
Response.Redirect("1.aspx")
End If

End Sub

方法二:
以下的Eval("ID")為GridView中的DataKeyNames

<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" CommandName ="111" CommandArgument ='<%# Eval("ID") %>'/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button2" runat="server" Text="Button" CommandName ="222" CommandArgument ='<%# Eval("ID") %>'/>
</ItemTemplate>
</asp:TemplateField>


Protected Sub gv_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv.RowCommand

If e.CommandName = "111" Then
Response.Write(e.CommandArgument)
Response.Write(gv.Rows(e.CommandArgument).Cells(1).Text)
End If

If e.CommandName = "222" Then
Response.Redirect("1.aspx")
End If

End Sub