页面文件
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpLoad.aspx.cs" Inherits="up_UpLoad" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" ><head run ...
1.遍历TreeView
调用 GetAllNode(TreeView.Nodes);
private void GetAllNode(TreeNodeCollection tnc) { foreach (TreeNode tn in tnc) { tn.Text = tn.Te ...
TextReader tr = new StreamReader("路径");
string strBody = tr.ReadToEnd()
// 添加引用->Com->Microsoft Excel 12.0 Ojbect Library
using Excel = Microsoft.Office.Interop.Excel;
string excelPath = @"C:\Documents and Settings\ch\Desktop\transaction.xls";
// 创建一个新Excel的Application
Excel.Application app = new Excel.ApplicationClass();
// 设置界面是 ...
<asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" Rows="10" onkeydown="DoKeyPress(500)" onPaste="CheckPaste(500)">
<script type="text/javascript">
function DoKeyPress(maxLen){
var str=event.srcElement.value;
var oSR=document.s ...
Response.Clear(); //清除缓冲区流中的所有内容输出
Response.Buffer = true; //
Response.Charset = "GB2312"; //设置输出流的http字符集
//保存附件用"attachment;filename=bang.xls";在线打开用"online;filename=bang.xls"
//可以是.doc、.xls、.txt、.htm、
Response.AppendHeader("Content-Disposition", "attachme ...
/// <summary>
/// 下载文件
/// </summary>
/// <param name="vPath">文件路径(绝对路径)</param>
public static void DownloadData(string path)
{
if (File.Exists(path))
{
FileInfo DownloadFile = new FileInfo(path);
System.Web.HttpContext.Current ...
OnClientClick="this.disabled=true;this.form.submit();" UseSubmitBehavior="False"
在按钮属性中加入这段代码
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count;i++ )
{
HttpPostedFile file = files[i] as HttpPostedFile;
string path = Server.MapPath("/UpLoadImg/"); // 上传路径
// 得到上传的文件名
...
把项目中的所有提示信息放在xml文件中,便于管理
处理类:
using System;
using System.Xml;
using System.Collections;
using BMS.Common.Config;
namespace BMS.Common
{
///
/// Summary description for Message.
///
public class JXMessage
{
private static IDictionary di ...
using System;
using System.Text.RegularExpressions;
namespace BMS.Common
{
public class JXType
{
///
/// 判断是否是整数
///
  ...
/// 获得客户端IP
///
///
private string getIp()
{
// 穿过代理服务器取远程用户真实IP地址
string Ip = string.Empty;
...
首先先用ViewState把要编辑记录的ID保存起来,然后在GridView行显示事件(RowDataBound)里判断,在ViewState里存的有ID时显示编辑文本框,
ASPX.CS类文件
using System;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
usi ...
public static DataTable GetDataTable(int rowNo, int columnNo)
{
if (rowNo > 0 && columnNo > 0)
{
DataTable dt ...
可以在GridView的数据源前插入一条记录,如:若数据源是datatable,就插入一个row到datatable的第一行
然后再把GridView的编辑行设置成第一行,即GridView.EditIndex = 0
这样就可以利用GridView的编辑功能来进行添加了







评论排行榜