Jump to content
Xtreme .Net Talk

djpaz25

Members
  • Posts

    12
  • Joined

  • Last visited

djpaz25's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Checking Value of Datagrid Cells OK, it appears that the datagrid.databind resets the format on the datagrid. I can actually live with that if I databind (sort) first and then make changes to cell appearances in the datagrid. My new problem is that I can't set a cell's color based on the datatable's value any more because the sort changes the relationship between the grid and the dataset. After the sort, the second "row" of the dataset isn't necessarily displayed in the second row of the datagrid. Instead of checking the value of myDataset.myDataTable(i).STATUS , I thought I could check the value of myDatagrid.items(i).cells(1).text (The STATUS value is stored in the 1st column.) However, myDatagrid.items(i).cells(1).text always seems to be Nothing, even after I do DataBind. I can do myDatagrid.items(i).cells(1).text = "Something", and it will display "Something". However, I can't seem to check the value. Thanks for any help.
  2. I originally had a datagrid bound to a dataset. After loading the dataset, I would loop through it and make changes to the datagrid background colors based on values in the dataset. The code was something like: if myDataset.myDataTable(i).STATUS = "C" then myDatagrid.items(i).cells(1).BackColor = Color.Red end if That worked fine. I now have to added sorting capability. I've bound the datagrid to a dataview so that I can set the dataview.sort property. The problem now is that when I do a datagrid.databind, I loose the formatting of the datagrid. It does do the sorting though. Any ideas on how I can do both the sorting and make changes to individual cell appearances?
  3. Have a datagrid bound to dataview. Initial Dataview.Sort is empty. Datagrid displays fine initially. After clicking on a column header, the datagrid comes back empty. The DataGrid_SortCommand is simply: DataView1.Sort = e.SortExpression DataGrid1.DataBind() The datagrid does display properly (including being sorted) if I re-retrieve the data in the DataGrid_SortCommand: DataView1.Sort = e.SortExpression SqlDataAdapter1.Fill(DsCategories1) DataGrid1.DataBind() I shouldn't have to re-retrieve the data, should I? I've read other posts that the datagrid is kind of funky, but what I'm doing comes right from the examples. Any thoughts?
  4. Have a DropDownList on a Web Form. In the DDL's SelectedIndexChanged event handler, I do things based on the selection. The problem is that the SelectedIndexChanged doesn't fire if the user drops down the list but chooses the first item on the list. I understand why it doesn't fire, since the index doesn't change. What event do I want to look at that will fire when the user clicks on the drop down list but doesn't change the selection? Or can I have no index selected when presenting to the user so that any change he makes fires SelectedIndexChanged? Thanks.
  5. I have a read-only Datagrid in a Web form. It gets bound to a dataset. I'd like to format a row in the datagrid based on a value in that row. Specifically, I'd like to set the color of a row in the datagrid based on the value of one of the fields in the corresponding dataset row. I see much about formatting a column, but nothing about formatting a row (except for things like setting alternating colors). Is this possible? Any hints appreciated.
  6. Thank you for taking the time to answer. That helps, but my real problem is in defining the UpdateCommand for the DataAdapter. How do I do that when I am potentially updating dozens of fields? And what if some of the fields are Null?
  7. I'm a VB6 programmer comfortable with ADO who is trying to use ADO.Net. I'm using an Access database. I have a Dataset defined that matches the structure of an Access table. My dataset has only a single record in it, and I populate the fields in the dataset programmatically. So far, so good. It's now time to store those values in the database. I know the value of the key field, which is unique. So one option is to create a DataCommand and build the CommandText in the form: Update Table Set Field1 = Value, Field2 = Value Where KeyField = Value and do an ExecuteNonQuery There are two problems with that. One is that I have about 30 fields, so that is going to be quite an SQL string. Plus some of the fields are null, which complicates things. Secondly, I have a dataset already defined, so I thought using a DataAdapter would be easier. I've been messing around with the DataAdapter's UpdateCommand, but I'm not sure how to use that with the dataset. I can set the UpdateCommand to Update Table Set Field1 = ?, Field2 = ? where KeyField = ? but then I (apparantly) have to define a parameter collection that includes all 30 parameters, set their types, and then copy the values from the dataset to the parameters. Is there some easier way? Can the parameter collection be defined automagically from the dataset? What form should the UpdateCommand's CommandText take? And on the subject of nulls (or DBNulls), how can I set the value of a field so that its value in the database is null? When defining a dataset, does a particular property need to be set to enable null values for a field? ADO recordsets sure seemed simpler than these disconnected ADO.Net datasets. Thanks for any help.
  8. Found File Thanks for the help. I ended up finding the reference in the .vbproj file. I had done a search on the files in the directory looking for the name of the missing file. That search turned up empty for some reason. However, I was able to edit the vbproj file and remove the reference to the missing file. Thanks again.
  9. I'm getting a message when I do a build that says, "Unable to open module file 'c:\WinOilsDev\Copy of dsSmallLabel.vb'. The system cannot find the file specified." That file wasn't needed by the project (or so I thought) and I deleted it. I can't find what remaining form/module/file is referring to the missing one. I did a text search within the project and a search on the files comprising the project, but none seem to be referring to the missing file. Any ideas on how I can find the referring file? BTW, the location of the error is given as line 0 of the missing file. Thanks
  10. Thank you, that was it! I have to do a MyDataSet.TableName(0).EndEdit for it to recognize the changes to the dataset. After doing that, HasChanges comes back as true. I've been pounding my head for a couple of days over that one. Am I the only one who thinks that ADO was simpler than ADO.Net?
  11. I sure hate to diagree with a Super Moderator :-), but I've searched the whole project and don't have AcceptChanges called anywhere. Is it possible that a setting I have for the Dataset or DataAdapter or Connection might be affecting this? My data source is Access, if that makes any difference.
  12. I'm having a problem with my program not recognizing changes in a dataset. I have some text boxes bound to fields in a dataset. I retrieve the data OK and modify the value in the text box. Through the debugger, I verify that the value in the dataset has been changed, e.g. dstest.tablename(0).fieldname has the modified value. However, dstest.haschanges comes back as false. dstest.tablename.rows(0).rowstate come back as unmodified Retrieving dstest.getchanges() returns nothing Why wouldn't the program recognize that the dataset has changed? Thanks.
×
×
  • Create New...