2014年7月18日 星期五
[ASP.NET] 使用vs 2013 express開發專案,web form只有原始檔頁面可查看,無預視的[設計]頁面?
檢查[工具 | 選項], [HTML設計工具]項目中的[啟用HTML設計工具]項目是否有勾選, 若無, 則請勾選後重新啟動Visual Studio
2014年7月15日 星期二
[ASP.NET]網頁導向
方法
1. 超連結
2. PostBackURL
3. Response.Redirect("~/Target.aspx")
4. Server.Transfer("~/Target.aspx") ->good
隱藏Target.aspx 位址
效率高
1. 超連結
2. PostBackURL
3. Response.Redirect("~/Target.aspx")
4. Server.Transfer("~/Target.aspx") ->good
隱藏Target.aspx 位址
效率高
2014年3月31日 星期一
[ASP.NET]修改從資料庫select出的資料存入datatable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
BindGridView();
}
private string GetConnectionString(){
return WebConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString;
}
private void BindGridView()
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection(GetConnectionString());
try
{
connection.Open();
string sqlStatement = "SELECT * FROM mytest";
SqlCommand sqlCmd = new SqlCommand(sqlStatement, connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{ dt.Rows[i][1] = ((string)dt.Rows[i][1]).Substring(0,1)+"O O"; }
//ds.Tables["test"].Rows[e.RowIndex]["test_time"] = my_test_time.Text;
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Fetch Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
connection.Close();
}
}
private void PrintRows(DataSet dataSet)
{
// For each table in the DataSet, print the row values.
foreach (DataTable table in dataSet.Tables)
{
foreach (DataRow row in table.Rows)
{
foreach (DataColumn column in table.Columns)
{
Console.WriteLine(row[column]);
}
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
BindGridView();
}
private string GetConnectionString(){
return WebConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString;
}
private void BindGridView()
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection(GetConnectionString());
try
{
connection.Open();
string sqlStatement = "SELECT * FROM mytest";
SqlCommand sqlCmd = new SqlCommand(sqlStatement, connection);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{ dt.Rows[i][1] = ((string)dt.Rows[i][1]).Substring(0,1)+"O O"; }
//ds.Tables["test"].Rows[e.RowIndex]["test_time"] = my_test_time.Text;
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Fetch Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
connection.Close();
}
}
private void PrintRows(DataSet dataSet)
{
// For each table in the DataSet, print the row values.
foreach (DataTable table in dataSet.Tables)
{
foreach (DataRow row in table.Rows)
{
foreach (DataColumn column in table.Columns)
{
Console.WriteLine(row[column]);
}
}
}
}
}
2014年3月25日 星期二
使用sql2005和vs2008時 利用自動SqlDataSource產生資料Insert時 對應的DbType會自動產生Date而不是DateTime
使用sql2005和vs2008時 利用自動SqlDataSource產生資料Insert時
對應的DbType會自動產生Date而不是DateTime需要手動更新
<InsertParameters>
<asp:ControlParameter ControlID="TextBox1" DbType="Date" Name="test_time"
PropertyName="Text" />
</InsertParameters>
<InsertParameters>
<asp:ControlParameter ControlID="TextBox1" DbType="DateTime" Name="test_time"
PropertyName="Text" />
</InsertParameters>
ref:
http://forums.asp.net/t/1538329.aspx
對應的DbType會自動產生Date而不是DateTime需要手動更新
<InsertParameters>
<asp:ControlParameter ControlID="TextBox1" DbType="Date" Name="test_time"
PropertyName="Text" />
</InsertParameters>
<InsertParameters>
<asp:ControlParameter ControlID="TextBox1" DbType="DateTime" Name="test_time"
PropertyName="Text" />
</InsertParameters>
ref:
http://forums.asp.net/t/1538329.aspx
2014年3月13日 星期四
2014年3月12日 星期三
訂閱:
文章 (Atom)
讓ASP.NET網站在開發除錯時期擁有WEB.CONFIG文件轉換功能
ref: https://blog.kkbruce.net/2016/09/enabling-xml-document-transforms-for-all-asp-net-web-by-develop-time.html#.XoP1KGMzbRY
-
https://docs.microsoft.com/zh-tw/dotnet/framework/data/transactions/using-system-transactions-in-aspnet <system.web> <co...
-
x-ua-compatible 頭標籤大小寫不敏感,必須用在 head 中,必須在除 title 外的其他 meta 之前使用。 https://read01.com/zh-tw/KkDzm6.html#.WsGJSi5ubRY
-
IS NULL 判斷值是否為NULL 學號 成績 S0001 56 S0001 73 S0002 92 S0002 63 S0003 92 S0003 70 S0004 75 S0004 88 S0004 68 S0005 NU...