新闻发布系统(增删改页面)控件ID DataSourceID="SqlSource"==>DataSourceID="SqlDataSource1" 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 [HttpException (0x80004005): “DetailsView1”的 DataSourceID 必须是 IDataSource 类型的控件的 ID。未能找到 ID 为“SqlSource”的控件。] 关键是这里!你看看你的DetailsView1 的datasource绑定的是什么!确认是否正确 http://blog.csdn.net/robaot/archive/2009/09/28/4603305.aspxhttp://www.cnblogs.com/aaa6818162/archive/2009/05/07/1452016.html <%@ Page Language="C#" AutoEventWireup="true" CodeFile="newsAdminDetail.aspx.cs" Inherits="newsAdminDetail" validateRequest="false" %> <!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 id="Head1" runat="server"> <title>新闻公告系统-管理 </title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <a class="nav" href="newsAdmin.aspx">回到管理主页面 </a> <asp:LoginStatus ID="LoginStatus2" runat="server" CssClass="nav" LogoutAction="Redirect" LogoutPageUrl="~/news.aspx" /> </td> </tr> <tr style="font-size: 12pt; color: #000000"> <td> <img alt="" border="0" height="15" name="newsCenter_r3_c2" src="image/newsCenter_r3_c2.jpg" width="452" /> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr style="font-size: 12pt; color: #000000"> <td align="center" background="images/newsCenter_r4_c1.jpg" style="width: 644px"> <asp:LoginView ID="LoginView1" runat="server"> <AnonymousTemplate> <br /> <img src="image/shou.jpg" />请您先执行 <asp:LoginStatus ID="LoginStatus1" runat="server" /> 操作! <br /> <br /> </AnonymousTemplate> <LoggedInTemplate> <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BorderWidth="0px" Caption="新闻数据管理" CellPadding="4" CellSpacing="1" CssClass="forumline" DataKeyNames="news_id" DataSourceID="SqlSource" DefaultMode="Edit" Height="50px" Width="95%"> <CommandRowStyle HorizontalAlign="Center" /> <RowStyle CssClass="row1" HorizontalAlign="Left" /> <Fields> <asp:TemplateField HeaderText="类别"> <EditItemTemplate> <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue=' <%# Bind("news_type") %>'> <asp:ListItem Selected="True">政治 </asp:ListItem> <asp:ListItem>经济 </asp:ListItem> <asp:ListItem>文体 </asp:ListItem> <asp:ListItem>生活 </asp:ListItem> <asp:ListItem>其他 </asp:ListItem> </asp:DropDownList> </EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID="DropDownList2" runat="server" SelectedValue=' <%# Bind("news_type") %>'> <asp:ListItem Selected="True">政治 </asp:ListItem> <asp:ListItem>经济 </asp:ListItem> <asp:ListItem>文体 </asp:ListItem> <asp:ListItem>生活 </asp:ListItem> <asp:ListItem>其他 </asp:ListItem> </asp:DropDownList> </InsertItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="日期"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text=' <%# Bind("news_date") %>'> </asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:Label ID="Label1" runat="server" Text=" <%# System.DateTime.Now %>"> </asp:Label> </InsertItemTemplate> </asp:TemplateField> <asp:BoundField DataField="news_subject" HeaderText="标题" SortExpression="news_subject" /> <asp:BoundField DataField="news_editor" HeaderText="编辑者" SortExpression="news_editor" /> <asp:TemplateField HeaderText="内容"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Height="100px" Text=' <%# Bind("news_content") %>' TextMode="MultiLine" Width="450px"> </asp:TextBox> </EditItemTemplate> <InsertItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Height="100px" TextMode="MultiLine" Width="450px" Text=' <%# Bind("news_content") %>'> </asp:TextBox> </InsertItemTemplate> </asp:TemplateField> <asp:CommandField ShowEditButton="True" ShowInsertButton="True" /> </Fields> <AlternatingRowStyle CssClass="row2" /> </asp:DetailsView> </LoggedInTemplate> </asp:LoginView> </td> </tr> <tr style="font-size: 12pt; color: #000000"> <td style="height: 27px; width: 644px;"> </td> </tr> </table> </div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=" <%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [news] WHERE ([news_id] = ?)" OnInserted="SqlDataSource1_Inserted" OnUpdated="SqlDataSource1_Updated" DeleteCommand="DELETE FROM [news] WHERE [news_id] = ?" InsertCommand="INSERT INTO [news] ( [news_type], [news_subject], [news_content], [news_editor]) VALUES ( ?, ?, ?, ?)" UpdateCommand="UPDATE [news] SET [news_type] = ?, [news_date] = ?, [news_subject] = ?, [news_content] = ?, [news_editor] = ? WHERE [news_id] = ?"> <SelectParameters> <asp:QueryStringParameter Name="news_id" QueryStringField="news_id" Type="Int32" /> </SelectParameters> <DeleteParameters> <asp:Parameter Name="news_id" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="news_type" Type="String" /> <asp:Parameter Name="news_date" Type="DateTime" /> <asp:Parameter Name="news_subject" Type="String" /> <asp:Parameter Name="news_content" Type="String" /> <asp:Parameter Name="news_editor" Type="String" /> <asp:Parameter Name="news_id" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="news_type" Type="String" /> <asp:Parameter Name="news_subject" Type="String" /> <asp:Parameter Name="news_content" Type="String" /> <asp:Parameter Name="news_editor" Type="String" /> </InsertParameters> </asp:SqlDataSource> </form> </body> </html> 就这处DataSourceID="SqlSource"红线标记的,应改为DataSourceID = "SqlDataSource1" C#处理这样的WORD处理怎么搞? 传值过程中出现的异常,求解答 请教 GridView 的操作提示 获取时间问题 调用WebClient.UploadFile(@"c:\1.txt","file:///E:/") 上传文件, 报"对路径“E:\”的访问被拒绝"的异常 如何在一个FROM输入查询条件后,另一个窗口的datagridview显示查询数据。 编程小知识 如何实现Google搜索引擎那种的模糊查询 VS2008 按钮可以做成圆形么 请教个很简单的问题:按tab键后光标为什么不能转移? 谁能给我一段操作注册表,扫描无效文件的代码? 寻找.NET案例书籍,网上商店的.
关键是这里!你看看你的DetailsView1 的datasource绑定的是什么!确认是否正确
http://www.cnblogs.com/aaa6818162/archive/2009/05/07/1452016.html
<!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 id="Head1" runat="server">
<title>新闻公告系统-管理 </title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a class="nav" href="newsAdmin.aspx">回到管理主页面 </a>
<asp:LoginStatus ID="LoginStatus2" runat="server" CssClass="nav" LogoutAction="Redirect" LogoutPageUrl="~/news.aspx" />
</td>
</tr>
<tr style="font-size: 12pt; color: #000000">
<td>
<img alt="" border="0" height="15" name="newsCenter_r3_c2" src="image/newsCenter_r3_c2.jpg"
width="452" /> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr style="font-size: 12pt; color: #000000">
<td align="center" background="images/newsCenter_r4_c1.jpg" style="width: 644px">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<br />
<img src="image/shou.jpg" />请您先执行
<asp:LoginStatus ID="LoginStatus1" runat="server" />
操作! <br />
<br />
</AnonymousTemplate>
<LoggedInTemplate>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BorderWidth="0px"
Caption="新闻数据管理" CellPadding="4" CellSpacing="1" CssClass="forumline" DataKeyNames="news_id"
DataSourceID="SqlSource" DefaultMode="Edit" Height="50px" Width="95%">
<CommandRowStyle HorizontalAlign="Center" />
<RowStyle CssClass="row1" HorizontalAlign="Left" />
<Fields>
<asp:TemplateField HeaderText="类别">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue=' <%# Bind("news_type") %>'>
<asp:ListItem Selected="True">政治 </asp:ListItem>
<asp:ListItem>经济 </asp:ListItem>
<asp:ListItem>文体 </asp:ListItem>
<asp:ListItem>生活 </asp:ListItem>
<asp:ListItem>其他 </asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server" SelectedValue=' <%# Bind("news_type") %>'>
<asp:ListItem Selected="True">政治 </asp:ListItem>
<asp:ListItem>经济 </asp:ListItem>
<asp:ListItem>文体 </asp:ListItem>
<asp:ListItem>生活 </asp:ListItem>
<asp:ListItem>其他 </asp:ListItem>
</asp:DropDownList>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="日期">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text=' <%# Bind("news_date") %>'> </asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:Label ID="Label1" runat="server" Text=" <%# System.DateTime.Now %>"> </asp:Label>
</InsertItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="news_subject" HeaderText="标题" SortExpression="news_subject" />
<asp:BoundField DataField="news_editor" HeaderText="编辑者" SortExpression="news_editor" />
<asp:TemplateField HeaderText="内容">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Height="100px" Text=' <%# Bind("news_content") %>'
TextMode="MultiLine" Width="450px"> </asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Height="100px" TextMode="MultiLine" Width="450px" Text=' <%# Bind("news_content") %>'> </asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
</Fields>
<AlternatingRowStyle CssClass="row2" />
</asp:DetailsView>
</LoggedInTemplate>
</asp:LoginView>
</td>
</tr>
<tr style="font-size: 12pt; color: #000000">
<td style="height: 27px; width: 644px;">
</td>
</tr>
</table>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=" <%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT * FROM [news] WHERE ([news_id] = ?)"
OnInserted="SqlDataSource1_Inserted"
OnUpdated="SqlDataSource1_Updated"
DeleteCommand="DELETE FROM [news] WHERE [news_id] = ?"
InsertCommand="INSERT INTO [news] ( [news_type], [news_subject], [news_content], [news_editor]) VALUES ( ?, ?, ?, ?)"
UpdateCommand="UPDATE [news] SET [news_type] = ?, [news_date] = ?, [news_subject] = ?, [news_content] = ?, [news_editor] = ? WHERE [news_id] = ?">
<SelectParameters>
<asp:QueryStringParameter Name="news_id" QueryStringField="news_id" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="news_id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="news_type" Type="String" />
<asp:Parameter Name="news_date" Type="DateTime" />
<asp:Parameter Name="news_subject" Type="String" />
<asp:Parameter Name="news_content" Type="String" />
<asp:Parameter Name="news_editor" Type="String" />
<asp:Parameter Name="news_id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="news_type" Type="String" />
<asp:Parameter Name="news_subject" Type="String" />
<asp:Parameter Name="news_content" Type="String" />
<asp:Parameter Name="news_editor" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</form>
</body>
</html> 就这处DataSourceID="SqlSource"红线标记的,应改为DataSourceID = "SqlDataSource1"