Jump to content
Xtreme .Net Talk

doraemon

Avatar/Signature
  • Posts

    36
  • Joined

  • Last visited

doraemon's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I tried the code (using VB equivalent). One thing funny I noticed was that if the datetimepicker was not checked and after running these 2 lines of codes, the check mark would be on. So, I have to add a condition to see if the datetimepicker is checked and if so the 2 lines would be executed; otherwise, nothing would happen. It is really weird that such a condition is put in. I don't know if it's a bug on the control.
  2. I am using a datetimepicker for the users to enter dates. I have the "ShowCheckBox" to be true so that if there is no date to be entered, the check box would be uncheckd. I came across with a problem. When the form is cleared, the user would like to have the date resetted to the current date. However, after I set the value to the current date, the check box is automatcially checked for me. I even have a line of code setting the Checked property to False right afterward but the box would still be checked. Is there soemthing I've done wrong? Right now I'm just forced to leave with the existing value and just set the Checked property to False. But the user would prefer to have it reset. Any suggestion?
  3. I created a crystal report for ASP .Net. Everything seems to work fine. But, when I want to print out the report, it will also print out the toolbar. I cannot make the toolbar invisible because without the toolbar the user won't be able to navigate to the next page. Is there a way to print out the report withou the toolbar?
  4. I don't know if this is possible. I have a form which the users enter some data. But I do not want the data to be saved to any database. I just want to produce a Crystal report with those data. Is this possible? I am very new to ASP .Net and don't know where to go from here. Any help will greatly be appreciated.
  5. I added some validation codes by using the AddHandler for the rowchanging event. The validation is to make sure that one date has to be later than another. When the program was run and I entered an invalid date, the validation was run and I got the error and a box asking if I want to correct the value. I clicked "Yes" and then for some reason the validation was ran a second time and I got a Microsoft Development Environment error ("An unhandled exception of type 'System.Exception' occurred in system.windows.forms.dll. Additional information: Due date must be after request date."). Then I had to "break" or "continue" (but the "continue" really just ended the program). I don't understand why the validation was run a second time (I found out about this when I stepped through the code). I thought when I throw an exception I should be brought back to editing the value. I swear that this was working at one point in time. But now it just does not work and I don't know what causes it. Anyone has any clue? And, this seems to happen only with new records. When I just updated an existing record, the validation would execute fine. Here's sample of my code: (Note: Due Date is not a required field; the validation would only take place if the user keys in the due date) AddHandler dataTable.RowChanging, New DataRowChangeEventHandler(AddressOf Row_Changed) Private Sub Row_Changed(ByVal sender As Object, ByVal e As DataRowChangeEventArgs) If e.Action = DataRowAction.Add Or e.Action = DataRowAction.Change Then If IsDBNull(e.Row("DueDate")) = False Then If e.Row("DueDate") < e.Row("RequestDate") Then Throw (New Exception("Due date must be after request date. ")) End If End If End IF End Sub
  6. I added a new record to the datagrid, programmatically setting some default values to the required columns, but if I don't make any changes to at least one cell and tried to click the save button, all the cells will be wiped out. And as I click the Save button I would get a message saying that there is nothing to save (I programmed the message it there when the user is trying to save a dataset with no changes). But, some fields are optional and if the default values are correct, there is really no need to make any change but just to insert the record as is. Is there anything I need to do to have the data stay? This is how I added the new record: CType(dg.DataSource, DataTable).DefaultView.AllowNew = True dg.CurrentCell = New(DataGridCell(_currencyManager.Count, 2) dg.Item(dgTaskAssignment.CurrentRowIndex, 1) = DefaultValue dg.Item(dgTaskAssignment.CurrentRowIndex, 3) = Today
  7. Here's a section of the codes: On the click of the parent's grid: dataset.Tables("Table1").Defaultview.rowfilter = myfilter . . . Then, on the delete button: Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim aTable As DataTable = dsTASKS.Tables("table2") If GetSelectedRows(ChildDataGrid).Count > 0 Then Dim o As Object For Each o In GetSelectedRows(ChildDataGrid) Dim aRow As DataRow = aTable.Rows(CInt(o)) aRow.Delete() Next o Try CType(ChildDataGrid.DataSource, DataTable).DefaultView.AllowDelete = True daChild.Update(dataset, "table2") dataset.AcceptChanges() CType(ChildDataGrid.DataSource, DataTable).DefaultView.AllowDelete = False Catch ex As SqlException dataset.RejectChanges() MessageBox.Show(ex.Message) End Try Else MessageBox.Show("No Rows selected for Deletion.") End If End Sub Public Function GetSelectedRows(ByVal dg As DataGrid) As ArrayList Dim al As New ArrayList Dim dv As DataView = CType(_currencyManager.List, DataView) Dim i As Integer While i < dv.Count If dg.IsSelected(i) Then al.Add(i) End If i = i + 1 End While Return al End Function ---- It would work if I did not have the rowfilter on the click of the parent's datagrid. But I need the rowfilter to show only the corresponding records in the child's datagrid. Also, I did not allow deleting of rows by hitting the delete key after selecting rows. That's why I had the allowdelete set to False and only made it true when the button was clicked. How can I get this to work?
  8. I have 2 datagrids, one parent and one child. When I delete a record in the child's table, the wrong record got deleted. I tried stepping through the code and I think it has to do with the rowfilter I have on the datatable of the child's table. The rowfilter is there so that when the user clicks on the parent's record, the child's datagrid will show the filtered corresponding records. But, when I tried to delete a child (let's say the first record), it would delete the first record of the table. How can I get this resolved?
  9. I wonder if there is any method/event to tell if the user goes from one row to another in the datagrid? There are rowchanged and rowchanging events; however, they won't fire unless there are things changed in the row. What I need to do is when the user clicks on any cell on another row, the child's datagrid will be refreshed. However, I could not get it working. The click event seems to only fire if the user clicks on "row heading" (the little box on the left). When they click on the cell, the click event did not seem to fire. So, I'm kind of thinking about putting codes in a selectedindexchange or currentrowindex change event but I do not seem to see such an option. Does anyone have any good suggestion?
  10. You can set the AllowNavigation property of the datagrid to False. This is a way to turn off the + symbol, but I don't know if this is the best way.
  11. Thanks. I've gotten it to work somewhat. However, it seems like when a new row is creaetd, the DefaultValue's function is not being run. For example, I assigned a function for creating the primary to the Default Value. However, the function is only run for the first time. Then when another row is created, I am getting the same primary key value as the first one. Is there a way to make sure that whenever a new row is creaetd, it's getting a new primary key? Or, is there a way I can force the users to save the row before allowing them to create or move on to another row?
  12. I have been searching through the column and knew that it's possible to do a dropdown list column in a datagrid in ASP .Net. But I could not find any example in doing so. I'm very new to ASP .Net. If anyone can provide any help or if there is a sample solution around, it will greatly be appreciated. Thanks.
  13. For the datagrid binding to a datatable, how can I not allow the user to go to another row without first saving the changes in the current row?
  14. I would like to see if I can add some custom codes when a new row is created in the datagrid. What I would like to do is to be able to assign a primary key to the row (rather than allowing the users to key it in), and select the first item in a combobox, etc. Is this possible? If so, how can I get it done? Another question relates to the combobox I have in the datagrid. I got it working quite well. However, I cannot get it to pick the first item by default. I could get it to display the first item, but if I have not changed it to something else or have not click on an item in the list, when I try to save it, the field value would show null. When should I change the code so that if a value is not picked, it will get the first item by default? Or perhaps if I can do the coding for the new row, then probably I can set it then. Any help will greatly be appreciated.
  15. Not when it's on the web, at least it did not do so on my web form.
×
×
  • Create New...