cndnbcn 0 Newbie Poster

So, I've been trying to get a page to update items in an MS SQL database forever now, trying different methods here and there having nothing working.

I finally got one method to work using a datagrid thing, and it's fine for the test table I'm using. But when it comes to the main tables, I want all of the columns to be editable and there are a ton of items, and a bunch of columns, so it's just a lot to display on one page. I got it so that I just pull one item at a time into the datagrid, but for a few of the fields with a lot of text, it can get jumbled with just a little text box. I pulled out the datagrid and have the information for the item populate into form fields, the only thing I'm having an issue with now is getting the button at the end of the form to execute the update command.

Any ideas?

I tried adding

private void submit_Click(Object source, SqlDataSourceStatusEventArgs e)

in the script section to see if that would do anything, but that just gives me an error.

Here is the code for the whole page (I deleted a lot of the extra form stuff just to cut down on the size of things for now)

<%@Page  Language="C#" %>
<%@Import Namespace="System.Web.Mail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
 private void OnDSUpdatedHandler(Object source, SqlDataSourceStatusEventArgs e) {
    if (e.AffectedRows > 0) {
        // Perform any additional processing, 
        // such as setting a status label after the operation.
        message.Text = Request.LogonUserIdentity.Name +
            " updated item successfully!";    
    }
    else {
        message.Text = "There was an error in updating the item.";
    }
 }
</script>

  <head runat="server">
    <title>Update Item</title>
</head>
<body>
    <form id="updateform" runat="server">

      <asp:SqlDataSource
          id="updatepopulate"
          runat="server"
          DataSourceMode="DataSet"
          ConnectionString="<%$ ConnectionStrings:MMconnect%>"
          SelectCommand="SELECT * FROM dummyitems WHERE ID=@ID"
          UpdateCommand="Update dummyitems SET item=@item,active=@active,special=@special,price=@price,store=@store,cat1=@cat1,sub=@sub,sub2=@sub2,age=@age,shortdesc=@shortdesc,desc1=@desc1,desc2=@desc2,desc3=@desc3,picth=@picth,pic1=@pic1,pic2=@pic2,pic3=@pic3,video=@video,vpath=@vpath,vend=@vend,weight=@weight,dateadd=@dateadd,altsearch=@altsearch,discount=@discount WHERE ID=@ID"
          OnUpdated="OnDSUpdatedHandler">
<SelectParameters> 
    <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="String"
                        DefaultValue="%" />
</SelectParameters>
      </asp:SqlDataSource>


<ASP:Repeater runat="server" DataSourceID="updatepopulate">
<ItemTemplate>
    
      <table width="95%">
         <tr>

  
            <td valign="top">

               <table>

	<tr>
		<td>Date Added:</td>
		<td><input type="text" disabled id="dateadd" size="15" runat="server" /></td>
	</tr>
	<tr>
		<td>active:</td>
		<td><input type="text" maxlength=1 size=1 value=<%# DataBinder.Eval(Container.DataItem, "active") %> id="active" runat="server"></td>
	</tr>
	<tr>
		<td>special:</td>
		<td><input type="text" value=<%# DataBinder.Eval(Container.DataItem, "special") %> id="special" runat="server">
	</td>
	</tr>
	<tr>
		<td>item number:</td>
		<td><input disabled type="text" maxlength=3 id="ID" length=3 runat="server" value=<%# DataBinder.Eval(Container.DataItem, "ID") %> /></td>
	</tr>
	<tr>
		<td>item name:</td>
		<td><input type="text" id="item" maxlength=255 value=<%# DataBinder.Eval(Container.DataItem, "item") %> runat="server" /></td>
	</tr>

                  <tr>
                     <td></td>
                     <td style="padding-top:15">
                        <!-- <input type="submit" name="updateitem" value="Update" runat="server"> -->
			<input type="submit" OnServerClick="update_Click" value="Update" runat="server">
                     </td>
                  </tr>

               </table>
            </td>
         </tr>
      </table>
</itemtemplate>
</asp:repeater>
   </form>





      <asp:Label
          id="message"
          runat="server">
      </asp:Label>

    </form>
  </body>
</html>