前言:當你從page1點選出page2時,在page2編輯完後,回到page1時,這時page1有得到編輯後的資料,可是再點選出page2,會發現顯示的資料是編輯前的,而非編輯後的!
如果確定資料已有寫入,而是在重新執行page後就沒這個問題的話,那可能要考慮是不是cache原因
解決方法
1、如是masterpage
在head下加入一行:
< equiv="Pragma" content="no-cache">
2、如是純page,在開啟URL加上亂數加以預防Cache
例如: showModalDialog("a.aspx?rnd=" + Math.random(),window);
2008年7月24日 星期四
繼上一篇 SQL多欄位合併,網頁連結的作法
2008年7月22日 星期二
SQL 多欄位合併成一個欄位的作法
declare @list nvarchar(max)
,@last bigint
set @list = ''
set @last = -1
-- 暫存所有查詢結果
create table #tmp_filelist(tmp_1 bigint, tmp_list nvarchar(max))
-- 暫存所有中間執行過程
create table #tmp_file(tmp_1 bigint,tmp_value nvarchar(60), list nvarchar(max))
--將需要的資料儲存在#tmp_file
insert into #tmp_file(tmp_1, tmp_value, list)
SELECT 資料來源
ORDER BY
--處理暫存表的list資料,利用@last來判斷是否要合併(重點:與前一筆資料作比對)
update #tmp_file set @list = list = (CASE WHEN @last <> tmp_1 THEN tmp_value ELSE @list + ',' + tmp_value END), @last =tmp_1
-- 將結果儲存在#tmp_filelist
insert into #tmp_filelist(tmp_1,tmp_list)
select tmp_1, max(list) from #tmp_file group by tmp_1
drop table #tmp_filelist
drop table #tmp_file
感謝Lillian的指導
,@last bigint
set @list = ''
set @last = -1
-- 暫存所有查詢結果
create table #tmp_filelist(tmp_1 bigint, tmp_list nvarchar(max))
-- 暫存所有中間執行過程
create table #tmp_file(tmp_1 bigint,tmp_value nvarchar(60), list nvarchar(max))
--將需要的資料儲存在#tmp_file
insert into #tmp_file(tmp_1, tmp_value, list)
SELECT 資料來源
ORDER BY
--處理暫存表的list資料,利用@last來判斷是否要合併(重點:與前一筆資料作比對)
update #tmp_file set @list = list = (CASE WHEN @last <> tmp_1 THEN tmp_value ELSE @list + ',' + tmp_value END), @last =tmp_1
-- 將結果儲存在#tmp_filelist
insert into #tmp_filelist(tmp_1,tmp_list)
select tmp_1, max(list) from #tmp_file group by tmp_1
drop table #tmp_filelist
drop table #tmp_file
感謝Lillian的指導
2008年7月20日 星期日
2008年7月10日 星期四
SQL 語句格式化數字(前面補0)方式
將一個數字例如33,或1使用t-sql語句轉換成033或001
以下是詳細分析:
1、select power(10,3)得到1000
2、select cast(1000+33 as varchar) 將1000轉換類型
3、select right(100033,3) 從右邊取3個字符得到033
將1格式化同上
select right(cast(power(10,3) as varchar)+33,3)
2008年6月29日 星期日
利用Menu及MultiView產生Tab效果
主要靠著「MutiView」分成多頁,以「MultiView1.ActiveViewIndex 」控制顯示哪一頁
參考網址:http://www.codeproject.com/KB/custom-controls/TabControl.aspx
參考網址:http://www.codeproject.com/KB/custom-controls/TabControl.aspx
容器的資料設定及狀態(GridView & Repeater)
GridView
protected void gvBBS_RowDataBound(object sender, GridViewRowEventArgs e) {
//定義一開始的網頁資料及狀態
if (e.Row.RowType == DataControlRowType.DataRow)
{
//使用版面內容
HyperLink hlkTitle = (HyperLink)e.Row.FindControl("hlkTitle");
if (hlkTitle != null)
hlkTitle.Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "bbs_title"));
hlkTitle.NavigateUrl = "BBSData.aspx?BBSNo=" + DataBinder.Eval(e.Row.DataItem, "bbs_bbsno");
}
}
Repeater
protected void rptBBS_ItemDataBound(object sender, RepeaterItemEventArgs e) {
if (e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
{
Button btnDeleteTitle = (Button)e.Item.FindControl("btnDeleteTitle");
if (btnDeleteTitle != null)
DelBtnSetup(btnDeleteTitle, "Title");
int lblno = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "lbl_lblno"));
}
}
protected void gvBBS_RowDataBound(object sender, GridViewRowEventArgs e) {
//定義一開始的網頁資料及狀態
if (e.Row.RowType == DataControlRowType.DataRow)
{
//使用版面內容
HyperLink hlkTitle = (HyperLink)e.Row.FindControl("hlkTitle");
if (hlkTitle != null)
hlkTitle.Text = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "bbs_title"));
hlkTitle.NavigateUrl = "BBSData.aspx?BBSNo=" + DataBinder.Eval(e.Row.DataItem, "bbs_bbsno");
}
}
Repeater
protected void rptBBS_ItemDataBound(object sender, RepeaterItemEventArgs e) {
if (e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
{
Button btnDeleteTitle = (Button)e.Item.FindControl("btnDeleteTitle");
if (btnDeleteTitle != null)
DelBtnSetup(btnDeleteTitle, "Title");
int lblno = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "lbl_lblno"));
}
}
訂閱:
文章 (Atom)