我的程序是主頁面放一個DataGrid,放員工信息,當然包括Empcode
現在就是要主管點一下該員工紀錄,然後按一下請假明細就彈出該員工的請假明細(子窗口)
點一下加班明細就彈出該員工的加班明細,現在功能已經都實現,但問題是每點一次
明細按鈕主頁面都要刷新,現在要求不能刷新應該怎麼作
現在就是要主管點一下該員工紀錄,然後按一下請假明細就彈出該員工的請假明細(子窗口)
點一下加班明細就彈出該員工的加班明細,現在功能已經都實現,但問題是每點一次
明細按鈕主頁面都要刷新,現在要求不能刷新應該怎麼作
datagrid 时 加上客户端代码就是,非常简单,何必再用 button.
四五十列,根本就放不下Button列其實不用Button也可以,可以用HyperLink,但我不知道怎麼傳動態參數,
HyperLink好像沒有事件可用
这段代码是用Empcode字段变成超级连接<ItemTemplate>
<a href="javascript:window.showModalDialog('WebForm2.aspx?value=<%# DataBinder.Eval(Container, "DataItem.Empcode") %>', window,'');">
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.title_id") %>'>
</asp:Label>
</a>
</ItemTemplate>
--datagrid整一行都链接上某页,选中行变色
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'") ;
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='LightGoldenrodYellow'") ;
string ContractName = DataBinder.Eval(e.Item.DataItem, "au_id").ToString();
string ContractID = DataBinder.Eval(e.Item.DataItem, "title_id").ToString();
e.Item.Style["cursor"] = "hand";
e.Item.ToolTip = ContractName;
e.Item.ForeColor=Color.Blue;
e.Item.Attributes.Add("onclick","window.open('webform1.aspx?value="+ContractID+"','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,revisable=no,left=100,top=0,width=600,height=450');");
}
}
但我想用Button表示比較清楚,不想用雙擊,因為那些
主管都是電腦BC,你要他們雙擊他們會很不爽,
如果用客戶端的Button控件應該怎麼接收事件
加入window.showModalDialog('WebForm2.aspx?value=Empcode);
不就行了?
window.open('http://localhost/TAS/HolidayDetail.aspx?Empcode=" + txtEmpcode.Text + "&Year=" + txtYear.Text + "','請假明細', 'top=50,left=100,width=700,height=600,toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,status=0');
{
if(!IsPostBack)
{
ArrayList al=new ArrayList();
al.Add("aa");
al.Add("bb");
al.Add("cc");
this.DataGrid1.DataSource=al;
this.DataGrid1.DataBind();
} }
在datagrid 得事件中加上
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
e.Item.Cells[0].Attributes.Add("onclick","window.open('http://localhost/TAS/HolidayDetail.aspx?Empcode=" + this.innerText+','請假明細', 'top=50,left=100,width=700,height=600,toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,status=0')");
}