Jump to content
Xtreme .Net Talk

VagabondSW

Avatar/Signature
  • Posts

    66
  • Joined

  • Last visited

Everything posted by VagabondSW

  1. I am fairly new to ASP.NET, so bear with me... I have a Datagrid with a data-bound DropDownList in the TemplateColumn. Here is the HTML code: <asp:TemplateColumn HeaderText="Void"> <ItemStyle horizontalalign="Left" wrap="False"></ItemStyle> <ItemTemplate> <%#Databinder.Eval(Container.DataItem, "isVoid")%> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlIsVoid" Runat="server" CssClass="ddl100"></asp:DropDownList> </EditItemTemplate> </asp:TemplateColumn> In Edit Mode, the end-user can select either True or False in the DropDownList, then save those changes. ALL of that is working correctly. The trouble comes when I try to deal with the value of that Datagrid column directly. It appears to always equate to String.Empty. Everytime the Datagrid is displayed, I go through the rows and change the Row forecolor to Red where the IsVoid column is True. Private Sub ColorVoidRows(ByVal dg As DataGrid, ByVal vindex As Integer) For Each item As DataGridItem In dg.Items If item.Cells(vindex).Text = "True" Then item.ForeColor = Color.Red End If Next End Sub This method works on a number of other Datagrid that can be displayed on the page, but those Datagrids don't have the templated IsVoid column. So, I figure it must have something to do with that. The Cells index is working and I have confirmed that I am looking at the correct column. My question is how do I retrieve that value from that TemplateColumn when I am NOT in Edit Mode? Any help is greatly appreciated.
  2. 7MB actually sounds a little low. Are you not using Visual Studio to create the application or did you build your application in Release mode? Remember, you're loading all the necessary .Net Framework libraries. Programming frameworks, like .NET and Java, are not for the minimalists among us.
  3. I just started with Visual Basic .NET in June 2005 because it was required at the last place I worked. In fact, it is the required language for my current contract as well. From 2001-2005, I was programming in C# with a few Visual Basic for Applications thrown in on the side. Oh yeah, I also had a healthy dose of NWScript (for the game Neverwinter Nights) thrown in as well. From 1995-2001, I was doing most of my coding in Visual Basic 5/6 and C. I also did a little bit of TCL (pronounced tickle). I tried cutting my teeth on C++ during this period, but it was not required for my job and the learning curve was otherwise too great to overcome "on the side". From 1991-1995, It was all UNIX all the time. I was programming in C with a heavy dose of shell scripting, including AWK, SED, TROFF and some PERL towards the end of that period. Prior to that it was BASIC, PICBasic, and Z80 assembly. My first BASIC program was written on a Tandy console and it calculated outcomes for mass combat under AD&D first edition rules.
  4. My suggestion is better than the VisualBasic helper functions (i.e. Left and InStr), but Marble's solution is the best one on the board so far.
  5. It is simple to do, but not necessarily simplistic. What I mean is the straight-forward methods that immediately pop to mind (Split on ".", Remove last three characters) don't work for all files. For example: "release notes 0.9a beta.html" So, we start with a String. Dim filename As String = "release notes 0.9a beta.html" We only want to strip off the file extension. Dim newString As String newString = filename.Substring(0, filename.LastIndexOf(".") + 1) That should get you where you want to go.
  6. Other interesting notes about String: 1. Strings reside on the managed heap rather than the stack, like other common primitive types, such as Integer and Boolean. Heap objects are cleaned up only when they are collected by the Garbage Collector while Stack objects are cleaned up as soon as they go out of scope. 2. Like most heap objects, Strings have a default value of Nothing (or null in C#) 3. Using the "&=" Visual Basic concatenation operators will not invoke the Microsoft.VisualBasic.CompilerServices library. It the equivalent of calling the String.Concat() method. 4. Using the the "&" Visual Basic concatenation operator WILL invoke the Microsoft.VisualBasic compatibility assemblies. 5. Using the Visual Basic "=" operator on strings WILL invoke the Microsoft.VisualBasic compatibility assemblies (e.g. If myString = "" Then). Use of String.Empty and the String.Length property can make the Visual Basic "=" unnecessary.
  7. Use AndAlso OrElse! I do programming in both VB.Net and C#. Here is a little blurb I wrote on the subject for some junior programmers on our team. Visual Basic .NET has the AndAlso and OrElse logical operators, which can perform the same functions as the And and Or operators with one key difference; they exhibit short-circuit behavior. Dim dt As DataTable If Not dt Is Nothing And dt.Rows.Count > 0 Then dt.Rows.Clear() End If In this example, we declare DataTable dt without the New keyword meaning any attempt to access the properties or methods of DataTable dt will cause the old "Object not set to an instance of an object" NullReferenceException. The previous If statement will throw a NullReferenceException because it uses the And operator to evaluate multiple expressions. The CLR would evaluate the first expression "Not dt Is Nothing" as false because dt is Nothing. However, the And operator directs the CLR to continue evaluating expressions. So, it would also attempt to access the Count property of the Rows collection, which will throw a NullReferenceException because dt is Nothing and therefore has no Rows collection let alone a Count property belonging to a DataRowCollection. The same NullReferenceException would occur if we used the Or operator. Fortunately, we can short circuit these expression evaluations by using the AndAlso and OrElse operators: Dim dt As DataTable If Not dt Is Nothing AndAlso dt.Rows.Count > 0 Then dt.Rows.Clear() End If This is the proper way to evaluate expressions and this new If statement will not cause a NullReferenceException. If the first condition of an AndAlso expression evaluates to false, the CLR stops processing conditions and returns False. The OrElse operator works slightly different. If the first condition of an OrElse expression is true, the CLR stops processing conditions and returns True. The And and Or operators still function as they always have for VB6 compatibility purposes. However, the new AndAlso and OrElse operators bring the short circuit functionality found in other languages to Visual Basic .NET and they are the default logical operators expression evaluations.
  8. The "Main" container form has its "IsMdiContainer" property set to True. If the "Child" Forms are launched from a method or event on the "Main" MdiContainer, then the MdiParent property of the Child forms is set to "Me".
  9. I have a ListBox control bound to an ArrayList: Dim m_expressionFilters As ArrayList Dim m_expressionBindingManager As BindingManagerBase m_expressionFilters = New ArrayList m_expressionBindingManager = BindingContext(m_expressionFilters) lstboxFilters.DataSource = m_expressionFilters When I add an Item to the ArrayList, that change is immediately reflected in the ListBox: m_expressionBindingManager.SuspendBinding() m_expressionFilters.Add(CurrentFilter) m_expressionBindingManager.ResumeBinding() However, when I call the Clear method of the ArrayList, the changes are not reflected in the ListBox: m_expressionBindingManager.SuspendBinding() m_expressionFilters.Clear() m_expressionBindingManager.ResumeBinding() At this point, the m_expressionFilters ArrayList has a Count of zero, but the Items formerly held in the ArrayList are still listed on the form in the ListBox. I have tried calling the Refresh and Update methods on the ListBox, but that produced no visible changes at all. Any help or advice would be greatly appreciated.
  10. Do you do something with your form to keep it Front or Top in the Z-Order?
  11. The short answer (the one I have time for now) is that you have to use XML DOM, which loads the entire document into memory, allows you to make edits, then writes it back to disk. The other option is to download the samples from Dino Esposito's book, Applied XML Programming for Microsoft .NET. Review the XmlReadWriter project under the Chap04 folder.
  12. The answer is Z order. Right-click the 2nd component that is filling the "whole form" and select 'Bring to Front' from the pop-up menu. That should get you the look you want.
  13. I am familiar with basic, brain-dead databinding, but I feel I need something a little more complex for my current application. I would like a few pointers or advice. I have a main form with a DataGrid bound to a DataView object. I have a custom control (DetailPanel), with a bunch of labels on it, that will display all the details related to the row selected in the DataGrid. How do I go about making sure the Labels on the DetailPanel display information related to the row currently selected in the DataGrid? I know how to create Binding objects on the DetailPanel that *should* display the appropriate column of data in the appropriate Label (an assumption at this point): Dim bindText As New Binding("Text", Me.DataSource, "myTable.myColumn") Label1.DataBindings.Add(bindText) Now, what do I need to link the Main Form and the custom control? Do I need a CurrencyManager? Two CurrencyManagers? Something else entirely? Any help or direction is greatly appreciated.
  14. Oh, I missed the academic pricing. The full retail price is around $250.
  15. In that case, you will have to count the rows returned by your query. If that count is less than your minimum number of rows, then you will have to create additional DataRow objects using DbNull.Value and add them to your Rows collection. To prevent the word "null" from appearing in all the empty cells, you will have to create a DataGridTextBoxColumn and set the NullText property to String.Empty. That DataGridTextBoxColumn will have to be added to a DataGridTableStyle, which in turn will be added to the TableStyles collection of your DataTable object. Adding the 'blank' rows should be simple. Here is the code for the ColumnStyles and TableStyles: Private Function GetGridStyle(ByVal table As DataTable) As DataGridTableStyle Dim dcc As DataColumnCollection Dim tableStyle As New DataGridTableStyle dcc = table.Columns For Each column As DataColumn In dcc tableStyle.GridColumnStyles.Add(GetTextBoxColumn(column)) Next With tableStyle .MappingName = table.TableName .ReadOnly = True .AlternatingBackColor = Color.AntiqueWhite .RowHeadersVisible = False End With Return tableStyle End Function Private Function GetTextBoxColumn(ByVal column As DataColumn) As DataGridTextBoxColumn Dim textBoxColumn As New DataGridTextBoxColumn With textBoxColumn .MappingName = column.ColumnName .HeaderText = column.Caption .NullText = String.Empty .ReadOnly = True End With Return textBoxColumn End Function I hope this helps.
  16. It would appear the Visual Studio 2005 Standard Edition will retail for less than $50. The features in the professional editions are a bit disappointing. In order to get the development and test operating systesms, you have to buy the VS2005 w/ MSDN Professional Subscription for an MSRP of $1200. That's also your only choice if you want the Microsoft Office tools AND mobile or 64-bit support. However, in order to get the development and test servers, you have to get VS2005 w/ MSDN Premium subscription for an MSRP of $2500. All I really care about are Windows Server 2003 and SQL Server 2005. I can get SQL Server Developer Edition in all versions, so that's covered. Does Windows Server 2003 come with the development and test operating systems or servers? By the way, knowing what we know now, the software being given away at the launch events is freely available for download to MSDN subscribers and certainly not worth the price of a plane ticket.
  17. Well, I noticed the San Francisco and Anaheim events are already closed. The only other one I'd be interested in attending would be the January 11 launch event in Washington DC, which is still open.
  18. You don't, as far as I know. What you can do is assign a DataColumn.Expression to a DataTable.Select method or a DataView.RowFilter property.
  19. The following line of code will pop open the application associated a given file type: System.Diagnostics.Process.Start(imageFilename)
  20. Did you first call the Open method of the connection object?
  21. I haven't run any tests on this yet, and it has been almost a year since I messed with Excel. However, I think you are running into a data type issue. If no type is specified, JET may use the first 20 rows to determine the data type for a particular column of data. In the example you give, if the first 20 or so rows are all Integer types, then any String value found after that may be read as DbNull. Having said that, I remember having some exceptions thrown in that case, but I could be remembering it wrong or you could masking the exception with an incomplete Try-Catch block. Sorry I couldn't be more help at this time, but at least we can take care of the easy stuff first.
  22. Here is a picture taken last month when I was volunteering in Waveland, Mississippi. http://home.san.rr.com/vagabondia/images/tmp/waveland.jpg
  23. San Diego, CA USA
×
×
  • Create New...