
tate
Avatar/Signature-
Posts
116 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by tate
-
Have you placed a populated label or something in the usercontrol to see if the usercontrol is being recognized correctly by the main aspx web form? I'm just guessing that the default web form does not have the correct link to the usercontrol.
-
If I understand correctly the data entered within a text box is used to increment an array list which also fills the datagrid. When all of the required data is entered, as validated by the datagrid content, the OnClick event of the submit button is used to update some database. Therefore, there is 2 unique things going on. I don't understand what you mean by DataTable. I would try to approach the OnClick event like; Define database connection Define data adapter Define dataset Use the fill method of the adapter to populate dataset Create CommandBuilder object Define a new row based on the data in the array Use the update method of the adapter to add new record to database
-
Did you try clearing the array that is bound to the datagrid as part of the submit event?
-
Make sure to check with your web host to determine if they have any restrictions. I use a web host that requires all database files to be placed in a specific folder that they set up for you like "_database". If I try to use some other path the web form will not function correctly.
-
I'm confused by your code. The Page tag indicates that you are using a code behind file yet you have placed script code within the web form. Shouldn't all of the script code be in the associated code behind?
-
Will you be using a web host server or will it be a IIS server you have set up?
-
The duplicates are present every time the page is loaded when the dataset object is decared globally. Yes the dataset is referenced in multiple event procedures that is why I need it to be global. If the dataset object is declared locally everything works great. However, I'm not able to access the dataset tables during other event procedures. In the actual project I'm working on the dataset is populated in the page_load. Then the calendar day_render compares the calendar day to the date within each dataset record. If the date matches then the calendar cell detail is added. Finally, when a specific date is selected additional detail for that day's events are posted in a datagrid. So you can see that there is a lot of interaction going on with the same dataset. You want to hear something even more interesting? If I develop the project in Visual Studio with code behinds the project works great. Unfortunately my client wanted to add the event calendar to an existing legacy HTML site. So I created a stand-alone *aspx page that the legacy pages link to. This approach was far more easier than updating everything to ASP.NET.
-
I have a very confusing problem with a calendar site I'm working on. To spare everyone from the actual pages of code I have created an condensed example that will illustrate my confusion. If I create a dataset locally within the page load event I return the exact number of records in the underlying database table just as I want to. However, if I declare the dataset variable as a global variable the same code returns a duplicate of each database record so I end up with 2x the records I should. Even though I don't believe post back to be the problem I have tried every possible combination of Not Page.IsPostBack control with no luck. I really need the dataset to be global so I can reference the data within the associated tables in multiple event triggers. I sure don't want to connect and gather data from the database every time I select a different calendar day. Anybody have some words of wisdom for me? Tate ~~~~~~~~~~~ Successful Code ~~~~~~~~~~~~~~~~~~~~~~~ ' Set up the database connection and load data Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Create connection Dim strConnect As String strConnect = "database" Dim odbcoEvent As OleDbConnection = New OleDbConnection(strConnect) ' Open connection odbcoEvent.Open() ' Create SQL command for data adapter Dim strItems As String strItems = "SELECT * FROM tblEvent" ' Create data adapter Dim odbdaEvents As OleDbDataAdapter = New OleDbDataAdapter(strItems, odbcoEvent) ' Create dataset and fill with data Dim dsEvents As New DataSet odbdaEvents.Fill(dsEvents, "Events") ' Create dataview Dim dv1 As New DataView(dsEvents.Tables("Events")) Repeater1.DataSource = dv1 Repeater1.DataBind() ' Close database connection odbcoEvent.Close() End Sub ~~~~~~~~~~~ Wrong Code Causing Duplicates ~~~~~~~~~~~~~~~ ' Declare global variables Dim dsEvents As New DataSet ' Set up the database connection and load data Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Create connection Dim strConnect As String strConnect = "database" Dim odbcoEvent As OleDbConnection = New OleDbConnection(strConnect) ' Open connection odbcoEvent.Open() ' Create SQL command for data adapter Dim strItems As String strItems = "SELECT * FROM tblEvent" ' Create data adapter Dim odbdaEvents As OleDbDataAdapter = New OleDbDataAdapter(strItems, odbcoEvent) ' Fill dataset with data odbdaEvents.Fill(dsEvents, "Events") ' Create dataview Dim dv1 As New DataView(dsEvents.Tables("Events")) Repeater1.DataSource = dv1 Repeater1.DataBind() ' Close database connection odbcoEvent.Close() End Sub
-
The links to the following two sites gave me enough information to allow me to create a similar page. Even though C# was utilized it only takes a little research to determine what VB technique should be used. http://www.macromedia.com/devnet/mx/dreamweaver/articles/aspnet_calendar_05.html http://www.c-sharpcorner.com/Code/2003/July/ASPNetCalendarControl.asp
-
Can you be a little more specific on how you are defining a webform and an example of what you hope to create? Will there be a new window or new *.aspx file?
-
I'm really confused! I created an ASP.NET project using Visual Studio that grabs data from an Access database to populate calendar cells. Everything worked great, only one data row reported per database record. Then my client asked to have the same calendar output to an existing *.htm legacy page. So, I archived all of the Visual Studio code behinds and modified the current *.htm page by adding the same scripts and asp controls then saved it as *.aspx. The page renders fine except now I have 2 rows (1 origianal & 1 copy) for each database record. Anybody have an idea why I get a copy of each record? I have verified that when the dataset fills there are twice the number of rows. Doesn't appear to be a postback issue since I have tried a version that accounts for the postback. Thanks Tate
-
I'm not familiar with C# but in VB I would do the following; As part of the login page you can pass the department number to the next form using either Request.Form or Request.QueryString methods. In the next form grab the value passed and assign it to a variable declared right after the <script> tag (before subroutines).
-
Datagrid Editcommand custom controls, and something else...
tate replied to Rothariger's topic in ASP.NET
I can't speak to your first question. However, to solve your second I would suggest not using the datagrid edit methods. Instead consider using a button in the datagrid row that will launch a seperate web form that is used to update the under lying database table. Using this technique then you can determine exactly how many fields can be edited. After updating the data you can redisplay the datagrid which will contained the refreshed data. -
Maybe this would work; Place some ASP.NET label or text box on your form that is made almost invisible by a 1px X 1px size. Within your JavaScript function or event triggered by the ASP.NET button assign a value to the label or text box. Then just check the value of the label or text box during the Page_Load event and make the decision what to do. Tate :D
-
Sounds like the datagrid is not being refreshed after you click add. If you are using an ASP.NET script on only 1 page to accomplish all of your tasks you may need rebind you datagrid. Another approach would be to use different pages based on function. The first page would provide a view of the current data. An AddItem button could then launch a seperate page which sole function is to add a record. After clicked Submit or Add your first page would be presented again. When the first page is loaded again it will automatically grab a refreshed version of the data.
-
Why do you suggest using the querystring instead of the request.form? From what I understand you can use either depending on which HTTP method used to submit the data. Request.Form requires POST while the querystring requires GET. In your experience is one better than the other?
-
Alright, I'm confused. I have an ItemMenu.aspx page that passes the value of ItemNum to my InsertItem.aspx page. Note that txtItemNum.Text is updated during the Page_Load event. I'm able to insert a new row into the "Items" table with the following SQL statement where ItemNum is hard coded; Sub Page_Load(Src As Object, E As EventArgs) strItemNum = Request.Form("ItemNum") txtItemNum.Text = strItemNum End Sub strSQL = "INSERT INTO Item (ItemNum, Description, ItemSuppNum, Cost, Price, UnitOfMeasure, OnHand) VALUES ('6668', '" & txtDescription.Text & "', '" & txtItemSuppNum.Text & "', " & dblCost & ", " & dblPrice & ", '" & txtUnitOfMeas.Text & "', " & intOnHand & ")" Now, when I try to use either of the variables strItemNum or txtItemNum in the following two SQL statements I get the same error; Error => Field 'Item.ItemNum' cannot be a zero-length string strSQL = "INSERT INTO Item (ItemNum, Description, ItemSuppNum, Cost, Price, UnitOfMeasure, OnHand) VALUES ('" & strItemNum & "', '" & txtDescription.Text & "', '" & txtItemSuppNum.Text & "', " & dblCost & ", " & dblPrice & ", '" & txtUnitOfMeas.Text & "', " & intOnHand & ")" strSQL = "INSERT INTO Item (ItemNum, Description, ItemSuppNum, Cost, Price, UnitOfMeasure, OnHand) VALUES ('" & txtItemNum.Text & "', '" & txtDescription.Text & "', '" & txtItemSuppNum.Text & "', " & dblCost & ", " & dblPrice & ", '" & txtUnitOfMeas.Text & "', " & intOnHand & ")" It appears I'm losing my value for some reason. Can anyone offer some advice? Thanks Tate
-
How about something like this; Dim ctrl As Control For Each ctrl In ctrlParent.Controls If TypeOf ctrl Is TextBox Then ctrl.Text = "" End If Next
-
Ooops... forgot to add how to use the <span>. TextBoxHolder.InnerHtml = "your text box code string"
-
Unfortunately I don't have time to wip up a sample but you might try researching the following approach; 1. Use a table with two cells for each row and place the CheckBoxList control in the first cell. 2. In the second cell use a <span id="TextBoxHolder" runat="server"/> tag to as a place holder. 3. During the load event setup a For loop that cycles from 0 to CheckBoxList.Items.Count-1 times. Each time through it dynamically creates a TextBox control with an id equivalent to the loop counter. Therefore, the id of the text box should be equivalent to the corresponding check box. 4. When the form is posted determine if a check box has been selected. If so use the Text property of the corresponding text box to display some message. I think this may work for you. Tate
-
Never used a GetValue method. Here is how I usually appoach it; <%@ Import Namespace = "System.Data.SqlClient" %> <html> <head> <title>Sample ASP.NET Page</title> </head> <script language = "VB" runat = "server"> Sub Page_Load(sender As Object, e As EventArgs) Dim ConnStr as String ConnStr = "Data Source=localhost; Integrated Security=SSPI;" ConnStr = ConnStr + "Initial Catalog=pubs" Dim conn As SqlConnection = New SqlConnection(ConnStr) Try conn.Open() Dim CmdStr As String CmdStr = "SELECT au_id,au_lname,au_fname FROM Authors" Dim cmd as SqlCommand = New SqlCommand(CmdStr,conn) Dim reader As SqlDataReader = cmd.ExecuteReader() Do While reader.Read() Authors.Items.Add(New ListItem(reader.Item("au_fname") _ + " " + reader.Item("au_lname"),reader.Item("au_id"))) Loop If Page.IsPostBack Then SelectedAuthor.Text=Authors.SelectedItem.Text End if Catch ex As SqlException Status.Text = ex.Message Finally conn.Close() End Try End Sub </script> <body> <h3>Using a DataReader object to retrieve data</h3> <form runat="server"> <asp:label id="Status" runat="server"/><br /> <asp:listbox id="Authors" rows=10 autopostback="true" runat="server"/><br /><br/> Selected author: <asp:label id="SelectedAuthor" runat="server"/> </form> </body> </html>
-
Placing your controls in a table can help with your formatting problem. Within the same row you can place the checkbox into the first cell and then place the corresponding text box in a second cell.