帮我看一下有什么问题 目前是gridview 选择之后detailsview仍旧没有出现
前面还经常在删除时报错 或者说该字符串未被识别为有效的日期时间 有一个从索引 0 处开始的未知字 我定义的是datetime型
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>后台管理页面</title>
</head>
<body>
<form id="Form1" runat="server">
<div style="text-align: center; background-image: url(Images/Main/BackColor.jpg);">
<table border="1" style="border-right: thin groove; border-top: thin groove; border-left: thin groove;
border-bottom: thin groove" width="948">
<tr>
<td style="width: 94px; position: static; height: 26px; text-align: left" valign="middle">
<asp:Image ID="Image1" runat="server" Height="55px" ImageUrl="~/Images/Main/logo1.jpg"
Width="81px" /></td>
<td style="width: 900px; position: static; height: 26px; text-align: right;" valign="middle">
<asp:Button ID="Button1"
runat="server" OnClick="Button1_Click" Text="退出后台" />
</td>
</tr>
<tr>
<td colspan="2" style="vertical-align: top; position: static; height: 450px; text-align: left"
valign="middle" enableviewstate="true">
<div style="text-align: center">
</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="AccessDataSource1" DataKeyNames="comment_user_name,comment_submit_time">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="comment_user_name" HeaderText="comment_user_name" ReadOnly="True"
SortExpression="comment_user_name" />
<asp:BoundField DataField="comment" HeaderText="comment" SortExpression="comment" />
<asp:BoundField DataField="comment_submit_time" HeaderText="comment_submit_time"
ReadOnly="True" SortExpression="comment_submit_time" />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/database.mdb"
SelectCommand="SELECT [comment_user_name], [comment], [comment_submit_time] FROM [comment]">
</asp:AccessDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="comment_user_name,comment_submit_time" DataSourceID="AccessDataSource2" Height="50px"
Width="125px">
<Fields>
<asp:BoundField DataField="comment_user_name" HeaderText="comment_user_name" ReadOnly="True"
SortExpression="comment_user_name" />
<asp:BoundField DataField="comment_submit_time" HeaderText="comment_submit_time"
ReadOnly="True" SortExpression="comment_submit_time" />
<asp:BoundField DataField="comment" HeaderText="comment" SortExpression="comment" />
<asp:BoundField DataField="user_name" HeaderText="user_name" SortExpression="user_name" />
<asp:BoundField DataField="submit_time" HeaderText="submit_time" SortExpression="submit_time" />
<asp:CommandField ShowDeleteButton="True" />
</Fields>
</asp:DetailsView>
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/database.mdb"
DeleteCommand="DELETE FROM [comment] WHERE (([comment_user_name] = ?)AND([comment_submit_time ]= ?) ) "
InsertCommand="INSERT INTO [comment] ([comment_user_name], [comment_submit_time], [comment], [user_name], [submit_time]) VALUES (?, ?, ?, ?, ?)"
SelectCommand="SELECT comment_user_name, comment_submit_time, comment, user_name, submit_time FROM comment WHERE ([comment_user_name] = ?) AND ([comment_submit_time] = ?)"
UpdateCommand="UPDATE [comment] SET [comment] = ?, [user_name] = ?, [submit_time] = ? WHERE (([comment_user_name] = ?)AND ([comment_submit_time] = ?)) ">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="comment_user_name"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="GridView1" Name="commet_submit_time" PropertyName="SelectedValue" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="comment_user_name" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="comment" Type="String" />
<asp:Parameter Name="user_name" Type="String" />
<asp:Parameter Name="submit_time" Type="DateTime" />
<asp:Parameter Name="comment_user_name" Type="String" />
<asp:Parameter Name="comment_submit_time" Type="DateTime" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="comment_user_name" Type="String" />
<asp:Parameter Name="comment_submit_time" Type="DateTime" />
<asp:Parameter Name="comment" Type="String" />
<asp:Parameter Name="user_name" Type="String" />
<asp:Parameter Name="submit_time" Type="DateTime" />
</InsertParameters>
</asp:AccessDataSource>
</td>
</tr>
<tr>
</tr>
</table>
</div>
</form>
</body>
</html>
前面还经常在删除时报错 或者说该字符串未被识别为有效的日期时间 有一个从索引 0 处开始的未知字 我定义的是datetime型
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>后台管理页面</title>
</head>
<body>
<form id="Form1" runat="server">
<div style="text-align: center; background-image: url(Images/Main/BackColor.jpg);">
<table border="1" style="border-right: thin groove; border-top: thin groove; border-left: thin groove;
border-bottom: thin groove" width="948">
<tr>
<td style="width: 94px; position: static; height: 26px; text-align: left" valign="middle">
<asp:Image ID="Image1" runat="server" Height="55px" ImageUrl="~/Images/Main/logo1.jpg"
Width="81px" /></td>
<td style="width: 900px; position: static; height: 26px; text-align: right;" valign="middle">
<asp:Button ID="Button1"
runat="server" OnClick="Button1_Click" Text="退出后台" />
</td>
</tr>
<tr>
<td colspan="2" style="vertical-align: top; position: static; height: 450px; text-align: left"
valign="middle" enableviewstate="true">
<div style="text-align: center">
</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="AccessDataSource1" DataKeyNames="comment_user_name,comment_submit_time">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="comment_user_name" HeaderText="comment_user_name" ReadOnly="True"
SortExpression="comment_user_name" />
<asp:BoundField DataField="comment" HeaderText="comment" SortExpression="comment" />
<asp:BoundField DataField="comment_submit_time" HeaderText="comment_submit_time"
ReadOnly="True" SortExpression="comment_submit_time" />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/database.mdb"
SelectCommand="SELECT [comment_user_name], [comment], [comment_submit_time] FROM [comment]">
</asp:AccessDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="comment_user_name,comment_submit_time" DataSourceID="AccessDataSource2" Height="50px"
Width="125px">
<Fields>
<asp:BoundField DataField="comment_user_name" HeaderText="comment_user_name" ReadOnly="True"
SortExpression="comment_user_name" />
<asp:BoundField DataField="comment_submit_time" HeaderText="comment_submit_time"
ReadOnly="True" SortExpression="comment_submit_time" />
<asp:BoundField DataField="comment" HeaderText="comment" SortExpression="comment" />
<asp:BoundField DataField="user_name" HeaderText="user_name" SortExpression="user_name" />
<asp:BoundField DataField="submit_time" HeaderText="submit_time" SortExpression="submit_time" />
<asp:CommandField ShowDeleteButton="True" />
</Fields>
</asp:DetailsView>
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/database.mdb"
DeleteCommand="DELETE FROM [comment] WHERE (([comment_user_name] = ?)AND([comment_submit_time ]= ?) ) "
InsertCommand="INSERT INTO [comment] ([comment_user_name], [comment_submit_time], [comment], [user_name], [submit_time]) VALUES (?, ?, ?, ?, ?)"
SelectCommand="SELECT comment_user_name, comment_submit_time, comment, user_name, submit_time FROM comment WHERE ([comment_user_name] = ?) AND ([comment_submit_time] = ?)"
UpdateCommand="UPDATE [comment] SET [comment] = ?, [user_name] = ?, [submit_time] = ? WHERE (([comment_user_name] = ?)AND ([comment_submit_time] = ?)) ">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="comment_user_name"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="GridView1" Name="commet_submit_time" PropertyName="SelectedValue" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="comment_user_name" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="comment" Type="String" />
<asp:Parameter Name="user_name" Type="String" />
<asp:Parameter Name="submit_time" Type="DateTime" />
<asp:Parameter Name="comment_user_name" Type="String" />
<asp:Parameter Name="comment_submit_time" Type="DateTime" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="comment_user_name" Type="String" />
<asp:Parameter Name="comment_submit_time" Type="DateTime" />
<asp:Parameter Name="comment" Type="String" />
<asp:Parameter Name="user_name" Type="String" />
<asp:Parameter Name="submit_time" Type="DateTime" />
</InsertParameters>
</asp:AccessDataSource>
</td>
</tr>
<tr>
</tr>
</table>
</div>
</form>
</body>
</html>
解决方案 »
- 类、方法
- 想知道用Membership有什么缺点?
- ajaxToolkit:CascadingDropDown 空间里的属性ServiceMethod调用含参数方法时,参数怎么传啊
- 请教;怎么样可以;将XML文件的内容显示在asp.net的页面上;而在源中没有任何htm标记
- 最近几天一直在用 java(SSH2)+easyUI
- [请问]object 定义的方法,或者变量是什么意思?怎么用的
- 点后浏览器的后退按扭,怎么能不让它不保持先原页面的状态,而是重新刷新页面?给出解决思路100重谢
- 一起讨论一下怎样做无刷新的聊天室?
- 新手求教,为什么我用localhost都没办法建立项目
- asp.net中怎么将浏览过的页面,形成快捷菜单
- win7 iis7 下调用tcpclient与本机的一个server通信的失败! 求解
- asp.net (C#) 学习疑问_radiobuttonlist控件 枚举值
所以不能所见即所得地设置AccessDataSource2的SelectParameters,
应该将一下前台代码删除,用后台代码来设置!
应该删除的代码:
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="comment_user_name" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="GridView1" Name="commet_submit_time" PropertyName="SelectedValue" />
</SelectParameters>后台设置在GridView1的SelectedIndexChanged事件中:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
AccessDataSource2.SelectParameters["comment_user_name"].DefaultValue = GridView1.SelectedDataKey.Values[0].ToString();
AccessDataSource2.SelectParameters["commet_submit_time"].DefaultValue = GridView1.SelectedDataKey.Values[1].ToString();
}
如上改了之后
“GridView1_SelectedIndexChanged”不是“ASP.backstage_aspx”的成员。是什么问题?
具体操作:
点中GridVew,在事件中找到SelectedIndexChanged事件,双击之!