- PR -

DataGridに作成したボタン列が10行を超えたときにイベントが無効

1
投稿者投稿内容
onabe
会議室デビュー日: 2005/06/15
投稿数: 1
投稿日時: 2005-06-16 00:54
いつも参考にさせていただいております。

現在、ASP.NET(C#)でファイルをDataGridで表示して欲しいファイルのみ選択してダウンロードさせる
アプリケーションを作成中です。

開発環境はVS.NET2003(.net framework 1.1),OSはWin2kです

DataGridにOnItemCommandを記述して、ButtonColomnを作成しています。
Buttonを押下するとDataGridの他の列で表示しているファイル名を取得して
ダウンロードする仕組みです。

しかし、ファイル数(DataGridの行数)が10個以上になるとButtonを押してもダウンロードされません。
ファイル数が9個以下の場合は正常にダウンロードできます。

この数を増やすことはできないでしょうか?

何かよい方法はないでしょうか?
よろしくお願いします。
(以下ソースです

//-- ソース ---------------------------------------------------
・HTML
<asp:DataGrid id="ItemsGrid"
OnItemCommand="ItemsGrid_Command"
AutoGenerateColumns="false"
runat="server">


<Columns>
<asp:ButtonColumn
HeaderText=" "
ButtonType="PushButton"
Text="download"
CommandName="Download"/>
</Columns>
</asp:DataGrid>

//--------------------------------------------------------------
・コード
protected void ItemsGrid_Command(object sender,DataGridCommandEventArgs e)
{
string strCommand = e.CommandName;

switch(strCommand)
{
case "Download":
string strFileName = ((TextBox)e.Item.Cells[0].Controls[1]).Text;

string strFilePath = ConfigurationSettings.AppSettings["path"];

Response.AddHeader("Content-Disposition","attachment;filename=" + HttpUtility.UrlEncode(strFileName) + "");
Response.ContentType = "application/octet-stream";
Response.WriteFile(strFilePath + strFileName + ".exe");
Response.End();
break;

default:
// do nothing
break;
}

}
1

スキルアップ/キャリアアップ(JOB@IT)