Hi there,
When i update an item within the datagrid the information just disappears. Here is the code if anybody can help. I assume the data being passed into the SQL is empty so how do I populate it?
<%
@ Page Language="VB" MasterPageFile="../Default.master" Title="Login" %>
<%
@ Register TagPrefix="Club" Namespace="Clubsite" %>
<%
@ Register TagPrefix="cutesoft" TagName="banner" Src="../vb/banner.ascx" %>
<%
@ Register TagPrefix="cutesoft" TagName="leftmenu" Src="../vb/leftmenu.ascx" %>
<%
@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
<%
-- Page layout --%>
<
asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<form id="form1" runat="server">
<
link href="../clubsite.css" rel="stylesheet" type="text/css" />
<div id="container">
<div id="centerblockheader">
News news Administration
</div>
<div id="rightblock">
<div class="adverts">
</div>
</div>
<div id="centerblock1">
<div>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
Height="50px" Width="580px" AllowPaging="True" BorderStyle="Solid"
CellPadding="5" BorderColor="White" DataKeyNames="newsID" PagerSettings-Mode="NextPrevious">
<Fields>
<asp:TemplateField HeaderText="News ID" InsertVisible="False">
<EditItemTemplate>
<asp:TextBox ID="HeadBox" runat="server" Text='<%# Bind("newsID") %>' Width="70px" ReadOnly="True"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="HeadLabel" runat="server" Text='<%# Bind("newsID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField> <asp:TemplateField HeaderText="Subject">
<EditItemTemplate>
<asp:TextBox ID="SubjectBox" runat="server" Rows="6" Text='<%# Bind("Subject") %>'
Width="450px" MaxLength="40"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorSubjectBox" runat="server" ControlToValidate="SubjectBox"
ErrorMessage="Please enter a subject" ValidationGroup ="EditValidationControls"></asp:RequiredFieldValidator>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="SubjectBox1" runat="server" Text='<%# Bind("Subject") %>' Width="450px" MaxLength="40"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorSubjectBox1" runat="server" ControlToValidate="SubjectBox1"
ErrorMessage="Please enter a subject" ValidationGroup ="EditValidationControls"></asp:RequiredFieldValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="SubjectLabel" runat="server" Text='<%# Bind("Subject") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle VerticalAlign="Top" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Details">
<EditItemTemplate>
<CE:Editor id = "DetailsBox" EditorWysiwygModeCss="../example.css" TemplateItemList="Bold,Italic,Underline" Height=150 Width=200 ShowBottomBar="false" Text = '<%#DataBinder.Eval(Container.DataItem, "Details") %>' runat = "Server" ></CE:Editor>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorDetailsBox" runat="server" ControlToValidate="DetailsBox"
ErrorMessage="Please enter details" ValidationGroup ="EditValidationControls"></asp:RequiredFieldValidator>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="DetailsBox1" runat="server" Text='<%# Bind("Details") %>' TextMode="MultiLine" Rows="6" Width="450px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorDetailsBox1" runat="server" ControlToValidate="DetailsBox1"
ErrorMessage="Please enter details" ValidationGroup ="EditValidationControls"></asp:RequiredFieldValidator>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="DetailsLabel" runat="server" Text='<%# Eval("Details").ToString().Replace(Environment.NewLine,"<br />") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle VerticalAlign="Top" />
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" ShowInsertButton="true" ValidationGroup="EditValidationControls"/>
</Fields>
</asp:DetailsView>
</
div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DBCONNECT %>"
SelectCommand="SELECT [newsID], [Subject], [Details], [Image] FROM [NEWS] ORDER BY [newsID] DESC"
InsertCommand="INSERT INTO [News] ([Subject], [Details]) VALUES (@Subject, @Details)"
UpdateCommand="UPDATE [NEWS] SET [Subject] = @Subject, [Details] = @Details WHERE [newsID] = @newsID">
<UpdateParameters>
<asp:Parameter Name="newsID"/>
<asp:Parameter Name="Subject"/>
<asp:Parameter Name="Details"/>
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Subject"/>
<asp:Parameter Name="Details"/>
</InsertParameters>
</asp:SqlDataSource>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ShowMessageBox="True" ShowSummary="False"
ValidationGroup="EditValidationControls" />
<br />
</div>
<
div id="centerblockfooter">
</div>
</div>
</form>
</
asp:Content>