可是hr的有很多不好之处,比如高度最大只有100px,两条并排的横线之间会有距离等。而用表格模拟就不会出现这样的问题。
1,
System.Web.UI.WebControls.FileUpload fupload_teacher_image;
在页面上声音上述控件
2,
在某按钮的事件下(.CS文件中)声音一个BYTE数组
byte[] bDefaultPhoto = fupload_teacher_image.FileBytes;
3.
声明SQL语句
string sql = "UPDATE TeacherClientConfig SET DefaultPhoto = @DefaultPhoto";
其中,DefaultPhoto的类型为IMAGE类型
4.
//构造参数
SqlParameter[] sqlParameter = {
new SqlParameter("@DefaultPhoto",SqlDbType.Image),
};
//为参数传值
int i = 0;
sqlParameter[i++].Value = bDefault;
5.
上传至数据库,因为DB层的写法谁跟谁的都不太一样,代码仅供参考
SqlCommand Command = new SqlCommand();
Command.Connection = Conn;
Command.Transaction = Trans;
Command.CommandText = SqlText;
Command.CommandType = CommandType.Text;
// 加入参数列表
if (Params != null)
{
for (int i = 0; i < Params.Length; i++)
Command.Parameters.Add(Params[i]);
}
nRet = Command.ExecuteNonQuery();
需要注意的地方,
new SqlParameter("@DefaultPhoto",
注意参数类型为SqlDbType.Image
6.
如何显示呢?跟普通的查询一样,首先查询出来这一列
const string SqlString = "SELECT WelcomePic FROM TeacherClientConfig";
7.
新建一个"一般性文件",扩展名为ASHX
打开它,写下类似下面的代码,测试吧!~
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/";)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class RenderImageWelcome : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/gif";
byte[] bDefaultPhoto = ACPublic.PubDbOperator.SelectConfigImageForWelcome();
if (bDefaultPhoto != null && bDefaultPhoto.Length > 0)
{
context.Response.Clear();
context.Response.Buffer = true;
context.Response.OutputStream.Write(bDefaultPhoto,bDefaultPhoto.Length);
context.Response.End();
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
在 HTML 代码中
<script language="javascript" type="text/javascript">
function clickbutton()
{
if(event.keyCode == 13)
{
window.document.all.button1.click();
}
}
</script>
<body onkeydown="if (event.keyCode == 13) return false;">
<asp:TextBox ID="textbox1" runat="server" onkeydown="clickbutton()"></asp:TextBox>
</body>
?
SELECT distinct review.reviewuser,review.reviewcontent,review.reviewtime FROM article INNER JOIN review ON article.articleid = review.articleid INNER JOIN userinfo ON article.userid = userinfo.userid 解释?
大家在删除有外键约束的数据的时候都是怎么处理的? 先删除外键在删除主键 存储过程写的效率比较高一点了
gridview 有时候用rows[i].cell[j]取不到值? 原因在于 用了模板列? <asp:TemplateField HeaderText="种类名称">
??????????????????????????????? <ItemTemplate>
??????????????????????????????????? <a href="#">
??????????????????????????????????????? <%#Eval("categoryname") %>
??????????????????????????????????? </a>
??????????????????????????????? </ItemTemplate>
??????????????????????????? </asp:TemplateField>
如果改成 <asp:boundfield datafield="categoryname" headertext="种类名称"/>就可以得到值了!!!
??????????????????????????
???????????????????????????
如何得到 datalist中按纽所在行的索引以及它的主键
(int)DataList1.DataKeys[((DataListItem)(((LinkButton)sender).Parent)).ItemIndex];
如个得到 GRIDVIEW中按纽所在行的索引以及它的主键
?public static int getGridViewRowIndex(object sender)
?????? {
?????????? System.Web.UI.WebControls.LinkButton bt = new System.Web.UI.WebControls.LinkButton();
?????????? bt = (System.Web.UI.WebControls.LinkButton)sender;
?????????? System.Web.UI.WebControls.GridViewRow gvr = ((System.Web.UI.WebControls.GridViewRow)(bt.Parent.Parent));
???????
?????????? return gvr.RowIndex;
?????? }
获取datalist内一行的某一个值的方法
? string picfile = ((HtmlAnchor)DataList1.Items[index].FindControl("file_name")).InnerText.ToString();
???? string picdes = ((Label)DataList1.Items[index].FindControl("Label3")).Text.ToString();
获取绝对路径的 相对路径
Request.PhysicalApplicationPath获取项目的跟目录的绝对地址
?protected string ConvertString(string absoluteness)??? {?????? ?????? int count = Request.PhysicalApplicationPath.Length;???????? string relety = absoluteness.Substring(count).Replace("//","/");????? return "../" + relety;???? ??? }