SIMPLE FORM to Database page

Results 1 to 2 of 2

Thread: SIMPLE FORM to Database page

  1. #1
    Join Date
    Dec 1969

    Default SIMPLE FORM to Database page

    I&#039;m just learning ASP.NET, and would like to learn a method to perform the following:<BR><BR>1) Connect to an oledb database, and populate the input text fields on a form. <BR>2) Allow the user to edit these form fields<BR>3) When the submit form button is selected, update the records in the database.<BR><BR>This could be used for many things, including changing a username and password.<BR><BR>Sounds very simple, but I haven&#039;t found an example yet. <BR><BR>Thanks,<BR><BR>Rick Brockman

  2. #2
    Join Date
    Dec 1969

    Default RE: SIMPLE FORM to Database page

    The .net Tutorial has some examples<BR>Lookup the book ASP.Net Tips,Tutorial and Code by sams publisher or Beginning ASP.Net Using VB.NET by WROX Page 516 more useful example<BR><BR>Some Idea for a Standard Web data entry form<BR>--------------------------------------------<BR><BR>You can use a DataGird with 1 custom &#060;asp:TemplateColumn&#062; and within the<BR>&#060;Itemtemplate&#062; and &#060;Edititemtemplate&#062; insert a table with 2 column and many rows<BR>on the first column of the table insert labels and the 2nd column insert the <BR>&#060;asp:textbox&#062; server control.<BR><BR>Use the [Edit][Update][cancel][Delete] onEvent_Click to control the &#060;asp:button&#062; activities<BR><BR>The tricky part is the [Add] you can use a ViewState("FormMode") = "Add" or "Edit"<BR>to pass the Modestate of the form so that when in [EDit] Mode the record Key is set to<BR>ReadOnly = True and in [Add] Mode it is set to ReadOnly = False so that you can enter<BR>a new record ID.<BR><BR>When in [Add] Mode init a newRow something like this<BR> Dim newRow As DataRow<BR> newRow = Dataset1.Tables(0).NewRow()<BR> newRow.Item("PartsCode") = "" &#039;+ Init NewRowRec Variables<BR> newRow.Item("CreationDATE") = Now<BR> newRow.Item("PartsDesc") = "" <BR> <BR> Dataset1.Tables(0).Rows.Add(newRow)<BR> Dataset1.Tables(0).DefaultView.Sort = SortFieldName &#039; + Init REC Key Sort Order <BR><BR> DGrid1.DataSource = Dataset1.Tables(0).DefaultView &#039; Session("SESDATA") = Dataset1<BR> DGrid1.PageSize = "1" &#039; Column Type data entry<BR> DGrid1.CurrentPageIndex = 0<BR> DGrid1.EditItemIndex = 0 <BR> DGrid1.PagerStyle.NextPageText = ""<BR> DGrid1.PagerStyle.PrevPageText = ""<BR> DGrid1.DataBind()<BR><BR>You can Dynamically generate the DropDownList or CheckBoxList within the Single column<BR>DataGrid ref to http://www/ [use a new SortedList()]<BR><BR>Use the Mvarkey = Trim(CType(e.Item.FindControl("PartsCode"), TextBox).Text) to get the<BR>value of the individual &#060;asp:textbox&#062; or server control fields when update or insert function<BR>to form up the SQL string. <BR> <BR>You will need to maintain 3 State Variables to make is behave like Windows Form Appn<BR>1) The ViewState("FormMode") or [Add][Edit][Browse]<BR>2) The ViewState("SQLString") = "SELECT * From PARTSMASTER Where ....] as the Record Source<BR>3) The ViewState("SecurityStr") to prevent Alien External pages from direct access <BR>4) Use the paging Function in the Datagrid to navigate between Next and Previous<BR><BR>The above is a brief possible solution.<BR><BR>Some books use a &#060;asp:Panel&#062; control column at the bottom of the form to implement<BR>the [Add] Forms mode.<BR>I think it is SAMS "Teach yourself in 21 days.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts