星期日, 1月 31, 2010

asp.net 不可以在 DropDownList 中選取多個項目。

今天遇到這個奇怪的bug,
不可以在 DropDownList 中選取多個項目。
上網查了一下,蠻多人有遇過這樣的問題:
不可以在 DropDownList 中選取多個項目 ?
OOP Pass by Value OR Reference ?
不過我的情形跟上述的不太一樣,
原來是我在DropDownList的item中已指定Selected="True"
又在程式指定一次
                if (hwCategory == "True")
                {
                    this.ddlPaidLimit.Items[1].Selected = true;
                }
                else
                {
                    this.ddlPaidLimit.Items[0].Selected = true;
                }
結果就發生這樣的錯誤,拿掉Selected="True"即可解決。


 

星期六, 1月 30, 2010

asp.net 無效的回傳或回呼引數處理

今天使用listview上的button進行delete的動作,
一postback就產生error,

錯誤訊息:「無效的回傳或回呼引數。已在組態中使用 或在網頁中使用 <%@ Page EnableEventValidation="true" %> 啟用事件驗證。基於安全性理由,這項功能驗證回傳或回呼引數是來自原本呈現它們的伺服器控制項。如果資料為有效並且是必需的,請使用 ClientScriptManager.RegisterForEventValidation 方法註冊回傳或回呼資料,以進行驗證。」
 
原因在於我在page_load中,有將資料動態繫結至listview,
導致postback就產生上述錯誤,
所以再綁定之前判斷資料是否為第一次載入即可。

 if (!IsPostBack){
                this.InitCoursePlans();
            }

星期日, 1月 24, 2010

DataList 自動編號

<div>
        <asp:DataList ID="DataListTestPaper" runat="server" DataKeyField="TestPaperItemID" DataSourceID="SqlDataSourceTestPaper" OnItemDataBound="DataList1_ItemDataBound" Width="736px" CellPadding="4" ForeColor="#333333">
            <ItemTemplate>
                        (<%# Container.ItemIndex + 1%>)
                        <!--試題id之後對答案要用到-->
                        <asp:Label ID="TestPaperItemIDLabel" runat="server" Text='<%# Eval("TestPaperItemID") %>' style="display: none;"></asp:Label>
                        
                        <asp:Label ID="TestPaerContentLabel" runat="server" Text='<%# Eval("TestPaerContent") %>'></asp:Label>
                        <asp:RadioButtonList ID="RadioButtonList1" runat="server" DataSourceID="SqlDataSourceOptions" DataTextField="TestPaperOptionsText" DataValueField="TestPaperOptionsID" RepeatDirection="Horizontal">
                        </asp:RadioButtonList>
                        <asp:SqlDataSource ID="SqlDataSourceOptions" runat="server" ConnectionString="<%$ ConnectionStrings:ELTestPaperConnectionString %>"
                            SelectCommand="SELECT TestPaperOptionsText, TestPaperOptionsID FROM TestPaperOptions WHERE (TestPaperOptionsPID = @pid)&#13;&#10;order by  newid() ">
                            <SelectParameters>
                                <asp:ControlParameter ControlID="TestPaperItemIDLabel" Name="pid" PropertyName="Text" />
                            </SelectParameters>
                        </asp:SqlDataSource>
            </ItemTemplate>
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <SelectedItemStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
            <AlternatingItemStyle BackColor="White" />
            <ItemStyle BackColor="#E3EAEB" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
        </asp:DataList><asp:SqlDataSource ID="SqlDataSourceTestPaper" runat="server" ConnectionString="<%$ ConnectionStrings:ELTestPaperConnectionString %>"
            SelectCommand="SELECT * FROM [TestPaper] where TestPaperCategoryID = @cid order by newid()&#13;&#10;">
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="1" Name="cid" QueryStringField="cid" />
            </SelectParameters>
        </asp:SqlDataSource>
    
    </div> 

星期二, 1月 19, 2010

C# DataTable Compute method 一行解決Sum問題

剛好需用到將datatable中的某一列做sum,
原來使用裡面提供的Compute就可以達到了Oops~
//課程作業已佔用的百分比
string hwPercentSum = this.dtHWList.Compute("sum(HomeWorkPercent)","").ToString();

Ubuntu ConnectTo WILE Using Iphon

ation:

Install the bluez-compat package.
Edit /etc/default/bluetooth to add the following lines:
1
PAND_ENABLED=1
2
PAND_OPTIONS="--role=PANU"
Restart the Bluetooth service: /etc/init.d/bluetooth restart
Add the BNEP network adapter to the /etc/network/interfaces file by appending the following line: iface bnep0 inet dhcp
Get the Bluetooth address of your phone by running hcitool scan and jotting down the address next to your phone’s name.
Now the bits and pieces that need to be done each time:

Pair your computer with your iPhone. If you’re using GNOME, the standard Bluetooth applet can handle that; presumably that’s true of the other flavours of Ubuntu as well.
To connect, run these commands in your favourite shell, replacing 00:aa:bb:cc:dd:ee with the Bluetooth address you jotted down earlier:
1
sudo pand --connect 00:aa:bb:cc:dd:ee -n
2
sudo ifup bnep0
At that point, life should be good and you should be connected. To disconnect later:
1
sudo ifdown bnep0
2
sudo pand -K

星期六, 1月 16, 2010

CIH套件

binutils
gcc
diffutils
gdb
util-linux-ng
mc

main()
{
    asm("nop");
    asm("nop");
    asm("nop");
    while("1");
    asm("nop");
    asm("nop");
}

星期四, 1月 14, 2010

C# StreamReader 逐行讀取txt file資料

今天又用到了XD,記錄一下。

  
using(StreamReader sr = new StreamReader(ckipPath,Encoding.Default))
{
while ((termTemp = sr.ReadLine()) != null)
{
termTemp = termTemp.Substring(0,termTemp.IndexOf(" "));
}
}

星期三, 1月 13, 2010

C# Base64 Convert

/// 
/// base64convert 的摘要描述
/// 
public class base64convert
{ 

    public base64convert()
    {
        
    }

    public string ConvertStringToBase64(string s)
    {
        byte[] ToByte = System.Text.Encoding.Default.GetBytes(s.ToString().Trim());

        string str = Convert.ToBase64String(ToByte);

        return str;
    }

    public string ConvertBase64ToString(string s)
    {
        byte[] strbyte = Convert.FromBase64String(s.ToString().Trim());
        string str = System.Text.Encoding.Default.GetString(strbyte);

        return str;
    }
}

星期一, 1月 11, 2010

SQL 選擇資料後馬上插入資料表XD

INSERT INTO MembersRole
                      (MembersRoleMemberID, MembersRoleOrgRoleID)
SELECT     MemberID, MemberRoleID
FROM         Members

星期五, 1月 01, 2010

其他你感興趣的文章

Related Posts with Thumbnails