悬赏100分 老师布置的ASP.NET题目 应该不难 斑竹和大家都来看看

yamijia 2005-03-23 03:38:53
要求用DATAGRID显示后台数据库里的一张表,DATAGRID里显示的每条记录都能手动输入文本类型的回复,并且能把此文本写入数据库,对此记录回复后此记录自动隐藏. 好象不难 可小弟初学ASP.NET 不知道该怎么做 -_-#
有没有真正的高人能够实际的指点一下,愿意送100分,给个例子也好,小弟还是学生,请各位大大帮忙

人人为我,我为人人



...全文
405 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
owenbeckham 2005-03-24
  • 打赏
  • 举报
回复

// get connection string from web.config
string strConnect = ConfigurationSettings.AppSettings["DsnWroxBooksOleDb"];

// create a SQL statement to select some rows from the database
string strSelect = "SELECT * FROM BookList WHERE ISBN LIKE '%07645437%'";

// create a variable to hold an instance of a DataReader object
OleDbDataReader objDataReader;

try
{
// create a new Connection object using the connection string
OleDbConnection objConnect = new OleDbConnection(strConnect);

// open the connection to the database
objConnect.Open();

// create a new Command using the connection object and select statement
OleDbCommand objCommand = new OleDbCommand(strSelect, objConnect);

// execute the SQL statement against the command to get the DataReader
objDataReader = objCommand.ExecuteReader();
}
catch (Exception objError)
{
// display error details
outError.InnerHtml = "<b>* Error while accessing data</b>.<br />"
+ objError.Message + "<br />" + objError.Source + "<p />";
return; // and stop execution
}

// set the DataSource property and bind the grid
MyDataGrid.DataSource = objDataReader;
MyDataGrid.DataBind();
}

</script>

<!--------------------------------------------------------------------------->

</body>
ziyan0218 2005-03-24
  • 打赏
  • 举报
回复
好好看看MSDN吧
上面的例子足够你用了
gngnandgngn 2005-03-24
  • 打赏
  • 举报
回复
这个。。。。。
你自己去查查资料吧,
看看要就发发 2005-03-24
  • 打赏
  • 举报
回复
你太懒
zhangyong83415 2005-03-24
  • 打赏
  • 举报
回复
ASP:Label Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<ASP:TextBox id="txtTitle" Size="60"
Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>' runat="server" />
这就是核心啦
jiafan123 2005-03-24
  • 打赏
  • 举报
回复
对数据库的增删改查
用到ado。net
先要连接数据库
然后用sql增加修改删除数据库
b/s
还是
c/s
wjcking 2005-03-24
  • 打赏
  • 举报
回复
return; // and stop execution
}

// set the DataSource property and bind the grid
MyDataGrid.DataSource = objDataReader;
MyDataGrid.DataBind();
}

</script>

yamijia 2005-03-23
  • 打赏
  • 举报
回复
to:ShingU(行云流水)

好象没用-_-#
ShingU 2005-03-23
  • 打赏
  • 举报
回复
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe

试试看。
yamijia 2005-03-23
  • 打赏
  • 举报
回复
再请问各位大大一个小问题:
为什么我重装系统以后新建WEB项目的时候提示:指定的WEB服务器运行的不是ASP.NET1.1版本
可是我重装前用的也是这个版本啊,是不是IIS的版本不对?IIS需要什么版本才行?
yamijia 2005-03-23
  • 打赏
  • 举报
回复
我也去网上找了呀,可是没找到-_-#
jacklin_036 2005-03-23
  • 打赏
  • 举报
回复
up
yamijia 2005-03-23
  • 打赏
  • 举报
回复
To:kavencai(天堂里的猫)
我照您的意思去试试看,如果能够解决问题一定给分.
neeao 2005-03-23
  • 打赏
  • 举报
回复
楼主没装msdn???????????
lovelxj 2005-03-23
  • 打赏
  • 举报
回复
多去看看datagrid 的 MSDN
bergkamp_my 2005-03-23
  • 打赏
  • 举报
回复
以后的学生是不是只会复制粘贴了?
stoneyu 2005-03-23
  • 打赏
  • 举报
回复
呵呵..問題比較簡單,在問題表裏設個標誌,自動隱藏.selecteditem,實現選中項.
njuzgj 2005-03-23
  • 打赏
  • 举报
回复
呵呵,这个东西就不用劳斑竹大驾了吧

你到书店随便挑本关于ASP.NET类,只要牵扯数据库就肯定有的:)
kavencai 2005-03-23
  • 打赏
  • 举报
回复
哈哈,一大堆,自己慢慢看吧
kavencai 2005-03-23
  • 打赏
  • 举报
回复
<%@Page Language="C#"%>

<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.OleDb" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Editing Data in a DataGrid Control</title>
</head>
<body bgcolor="#ffffff">
<span class="heading">Editing Data in a DataGrid Control</span><hr />

<div id="outError" runat="server" />

<form runat="server">

<ASP:DataGrid id="MyDataGrid" runat="server"
CellPadding = "2"
EditItemStyle-BackColor="yellow"
DataKeyField="ISBN"
OnEditCommand="DoItemEdit"
OnUpdateCommand="DoItemUpdate"
OnCancelCommand="DoItemCancel"
AutoGenerateColumns="False">

<Columns>

<ASP:BoundColumn DataField="ISBN" HeaderText="ISBN" ReadOnly="True" />

<ASP:TemplateColumn HeaderText="Title">
<ItemTemplate>
<ASP:Label Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<ASP:TextBox id="txtTitle" Size="60"
Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>' runat="server" />
</EditItemTemplate>
</ASP:TemplateColumn>

<ASP:BoundColumn DataField="PublicationDate" HeaderText="Published" />

<ASP:EditCommandColumn
EditText="Edit"
CancelText="Cancel"
UpdateText="Update" />

</Columns>

</ASP:DataGrid>

</form>

<!--------------------------------------------------------------------------->

<script language="C#" runat="server">

void Page_Load(Object sender, EventArgs e)
{
if (!Page.IsPostBack)
BindDataGrid(); // create data set and bind to grid control
}


void DoItemEdit(Object objSource, DataGridCommandEventArgs objArgs)
{
// set the EditItemIndex property of the grid to this item's index
MyDataGrid.EditItemIndex = objArgs.Item.ItemIndex;
BindDataGrid(); // bind the data and display it
}


void DoItemUpdate(Object objSource, DataGridCommandEventArgs objArgs)
{
// get a reference to the title and publication date text boxes
TextBox objTitleCtrl = (TextBox)objArgs.Item.FindControl("txtTitle");
TextBox objPubDateCtrl = (TextBox)objArgs.Item.Cells[2].Controls[0];

// create a suitable SQL statement and execute it
string strSQL = "UPDATE Booklist SET Title='" + objTitleCtrl.Text + "', "
+ "PublicationDate='" + objPubDateCtrl.Text + "' "
+ "WHERE ISBN='" + MyDataGrid.DataKeys[objArgs.Item.ItemIndex] + "'";
ExecuteSQLStatement(strSQL);

// set EditItemIndex property of grid to -1 to switch out of Edit mode
MyDataGrid.EditItemIndex = -1;
BindDataGrid(); // bind the data and display it
}


void DoItemCancel(Object objSource, DataGridCommandEventArgs objArgs)
{
// set EditItemIndex property of grid to -1 to switch out of Edit mode
MyDataGrid.EditItemIndex = -1;
BindDataGrid(); // bind the data and display it
}


void BindDataGrid()
{
// get connection string from web.config
string strConnect = ConfigurationSettings.AppSettings["DsnWroxBooksOleDb"];

// create a SQL statement to select some rows from the database
string strSelect = "SELECT * FROM BookList WHERE ISBN LIKE '%07645437%'";

// create a variable to hold an instance of a DataReader object
OleDbDataReader objDataReader;

try
{
// create a new Connection object using the connection string
OleDbConnection objConnect = new OleDbConnection(strConnect);

// open the connection to the database
objConnect.Open();

// create a new Command using the connection object and select statement
OleDbCommand objCommand = new OleDbCommand(strSelect, objConnect);

// execute the SQL statement against the command to get the DataReader
objDataReader = objCommand.ExecuteReader();
}
catch (Exception objError)
{
// display error details
outError.InnerHtml = "<b>* Error while accessing data</b>.<br />"
+ objError.Message + "<br />" + objError.Source + "<p />";
return; // and stop execution
}

// set the DataSource property and bind the grid
MyDataGrid.DataSource = objDataReader;
MyDataGrid.DataBind();
}

</script>

<!--------------------------------------------------------------------------->

</body>
</html>


加载更多回复(4)
内容概要:本文系统介绍了软件知识产权的基础知识,涵盖软件合法持有人的权利、软件著作权的行使方式(许可与转让)、保护期限、相关法律基础及典型真题解析。重点阐述了《中华人民共和国著作权法》和《计算机软件保护条例》作为我国软件著作权保护的两大法律依据,明确了软件著作权的客体范围(源程序、目标程序、文档),指出软件开发思想不受保护,并区职务作品与委托开发作品的权属规则。同时讲解了专利权的地域性和先申请原则,以及商业秘密在软件保护中的应用。; 适合人群:从事软件开发、项目管理、知识产权管理等相关工作的技术人员与法务人员,以及准备软考或学习知识产权课程的学生。; 使用场景及目标:①帮助开发者明确自身在职务开发、委托开发中的权利边界;②指导企业合规使用软件并防范侵权风险;③辅助理解和应对软件著作权登记、专利申请、商业秘密保护等实务问题;④通过真题解析提升对法律法规的实际应用能力。; 阅读建议:本资料兼具理论性与实用性,建议结合具体工作场景对照条文理解,并重点关注历年真题部以强化对关键知识点的掌握,尤其注意区著作权、专利权与商标权的不同保护机制。
内容概要:本文提出了一种考虑极端天气下线路脆弱性的配电网布式电源配置优化模型,并基于IEEE33节点系统通过Matlab代码实现。该模型综合评估极端气象条件对线路故障概率的影响,构建线路脆弱性指标,结合布式电源(如风电、光伏等)的出力特性,优化其在配电网中的选址与定容方案。研究充考虑系统潮流约束、运行安全性、负荷需求响应以及不确定性天气因素,采用先进的智能优化算法求解多维非线性规划问题,旨在提升配电网在极端事件下的供电可靠性与系统韧性。通过仿真验证,该模型能有效降低停电风险、提高可再生能源消纳能力,并增强电网应对突发灾害的恢复能力。; 适合人群:具备电力系统析、优化建模与Matlab编程基础,从事智能电网、布式能源规划、配电网可靠性研究及相关领域的科研人员、高校研究生及工程技术人员。; 使用场景及目标:①用于极端气候条件下配电网抗灾能力的量化评估与规划决策;②指导布式电源在配网中的科学布局与容量配置;③提升电网在不确定环境下的运行稳定性与自愈能力;④为电力企业制定应急调度策略与基础设施加固方案提供理论支持和技术工具。; 阅读建议:建议结合提供的Matlab代码进行仿真实践,深入理解IEEE33节点系统的建模方法、极端天气建模逻辑与线路脆弱性量化机制,重点关注目标函数构造、约束处理及优化求解流程,便于将该模型拓展应用于其他网络拓扑或灾害场景。

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧