如何在datalist里面动态点击添加就添加一行?用来做添加的,
datalist左边显示数据,右边放几个按钮,添,删,改
当点击添加的时候就在下面添加一行,然后写入数据,;来做添加 ,修改亦如此
datalist左边显示数据,右边放几个按钮,添,删,改
当点击添加的时候就在下面添加一行,然后写入数据,;来做添加 ,修改亦如此
解决方案 »
- [对DataSet的结果集中的内容进行替换]
- 小白系列之有关select
- 请教usercontrol 不触发界面的问题
- 请问用asp.net如何去读取远程服务器上的access文件?
- NHibernate:No column name found for property 这是哪里出问题?
- 用ASP.NET生成EXCEL,请问怎样插入一张图片,谢谢?
- 网站设计思路,主要是新闻发布,但是信息比较多,需要经常更新。
- gif图片为什么停止不动,有何解决办法!!!
- 本人(.net开发-四川人)想到重庆发展 但不知道重庆的工资待遇怎么样?
- 同行们请帮忙,可编辑的下拉列表,在线等...
- 考试系统
- 帮我看一下代码中的“rdlog["sys_power"].ToString()”这一句应该怎么改才可以正常运行
----------------------------------------<%@ Page language="c#" Codebehind="Default.aspx.cs" AutoEventWireup="false" Inherits="Example.DataListTest" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>DataListTest</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<style type="text/css">TD { FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: "宋体" }
</style>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td><a href="DlNested.aspx">DataList嵌套实例</a></td>
</tr>
<tr>
<td>
<table cellSpacing="0" borderColorDark="white" cellPadding="0" width="100%" align="center"
border="1">
<tr>
<td><asp:datalist id="DataList1" runat="server" Width="90%" Height="280px" RepeatColumns="2" RepeatDirection="Horizontal"
RepeatLayout="Flow">
<headertemplate>
<table id="Table6" cellspacing="0" bordercolordark="white" cellpadding="0" width="100%"
border="1">
<tr>
<td width="80%"><font face="宋体">TypeName</font></td>
<td width="50"><font face="宋体">选择</font></td>
<td width="50"><font face="宋体">确定</font></td>
<td width="50"><font face="宋体">删除</font></td>
</tr>
</table>
</headertemplate>
<selecteditemtemplate>
<font face="宋体">
<table id="Table3" cellspacing="0" cellpadding="0" width="100%" border="1" bordercolordark="white">
<tr>
<td><font face="宋体">TypeID</font></td>
<td><font face="宋体" color="#ff3366"><font face="宋体">TypeName</font></font></td>
</tr>
<tr>
<td style="HEIGHT: 21px"><font face="宋体">
<asp:Label id=lblTypeID runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "I_TypeID") %>'>
</asp:Label></font></td>
<td style="HEIGHT: 21px"><font face="宋体" color="#ff3366">
<asp:Label id=lblTypeName runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "C_TypeName") %>'>
</asp:Label></font></td>
</tr>
<tr>
<td colspan="2">
<asp:Button id="btnBack" runat="server" CommandName="cancel" Text="返回"></asp:Button></td>
</tr>
</table>
</font>
</selecteditemtemplate>
<footertemplate>
<table id="Table8" cellspacing="0" bordercolordark="white" cellpadding="0" width="100%"
border="1">
<tr>
<td><font face="宋体">TypeID</font></td>
<td>
<asp:TextBox id="txtTypeIDInsert" runat="server"></asp:TextBox></td>
<td><font face="宋体">TypeName</font></td>
<td>
<asp:TextBox id="txtTypeNameInsert" runat="server"></asp:TextBox></td>
<td align="center">
<asp:Button id="btnInsert" runat="server" Text="新增" CommandName="Insert"></asp:Button></td>
</tr>
</table>
</footertemplate>
<itemtemplate>
<table cellspacing="0" cellpadding="0" width="100%" border="1" bordercolordark="white">
<tr>
<td width="80%"><font face="宋体" color="red">
<%# DataBinder.Eval(Container.DataItem,"C_TypeName")%>
</font>
</td>
<td width="50">
<asp:Button id="btnSelect" runat="server" CommandName="select" Text="选择"></asp:Button></td>
<td width="50">
<asp:Button id="btnModify" runat="server" CommandName="edit" Text="编辑" EnableViewState="true"></asp:Button></td>
<td width="50"><font face="宋体">
<asp:Button id=btnDelete runat="server" CommandName="delete" Text="删除" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "I_TypeID") %>'>
</asp:Button></font></td>
</tr>
</table>
</itemtemplate>
<edititemtemplate>
<table id="Table2" cellspacing="0" cellpadding="0" width="100%" border="1">
<tr>
<td style="WIDTH: 75px; HEIGHT: 23px"><font face="宋体"><font face="宋体">TypeName</font></font></td>
<td style="HEIGHT: 23px"><font face="宋体" color="#ff3366">
<asp:TextBox id=txtTypeName runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "C_TypeName") %>'>
</asp:TextBox></font></td>
</tr>
<tr>
<td style="WIDTH: 75px"><font face="宋体">
<asp:Button id=btnUpdate runat="server" CommandName="update" Text="更新" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "I_TypeID") %>'>
</asp:Button></font></td>
<td><font face="宋体" color="#ff3366">
<asp:Button id="btnCancle" runat="server" CommandName="cancel" Text="取消"></asp:Button></font></td>
</tr>
</table>
</edititemtemplate>
</asp:datalist></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<TABLE cellSpacing="0" borderColorDark="white" cellPadding="0" width="100%" border="1">
<TR align="center">
<TD noWrap width="10%">共
<asp:label id="lblRecNum" runat="server"></asp:label>条记录</TD>
<TD noWrap width="30%">第
<asp:label id="lblCurPageNO" runat="server"></asp:label>页/共
<asp:label id="lblPageNum" runat="server"></asp:label>页</TD>
<TD noWrap width="5%"><asp:button id="btnFirst" runat="server" Text="首页"></asp:button></TD>
<TD noWrap width="5%"><asp:button id="btnPreview" runat="server" Text="上页"></asp:button></TD>
<TD noWrap width="5%"><asp:button id="btnNext" runat="server" Text="下页"></asp:button></TD>
<TD noWrap width="5%"><asp:button id="btnLast" runat="server" Text="末页"></asp:button></TD>
<TD noWrap width="20%">每页<asp:dropdownlist id="ddlPageRowNum" runat="server" AutoPostBack="True"></asp:dropdownlist>行</TD>
<TD noWrap width="20%">转到
<asp:dropdownlist id="ddlJumpToPageNum" runat="server" AutoPostBack="True"></asp:dropdownlist>页</TD>
</TR>
</TABLE>
</td>
</tr>
</table>
</form>
</body>
</HTML>
DataTable dt = (DataTable)ViewState["Table"];
DataRow dr = dt.NewRow();
dr[0] = "";
dt.Rows.Add(dr);
dt.AcceptChanges(); DataTable dt = (DataTable)ViewState["Table"];
datalist1.DataSource = dt;
datalist1.DataBind();