Jump to content
Xtreme .Net Talk

wsyeager

Avatar/Signature
  • Posts

    140
  • Joined

  • Last visited

Everything posted by wsyeager

  1. I am using the Gridview control without a DataSource control. When I click on the Edit button, the page posts back and enters the following code: Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing Try Dim row As GridViewRow = GridView1.Rows(e.NewEditIndex) [b]Dim ddlCustomerID As DropDownList = row.FindControl("ddlCustomerID")[/b] ddlCustomerID.DataSource = dstCustomers ddlCustomerID.SelectedIndex = ddlCustomerID.Items.IndexOf(ddlCustomerID.Items.FindByValue(dstCustomers.Tables(0).Rows(row.RowIndex).Item("CustomerID"))) ddlCustomerID.DataBind() Catch ex As Exception Response.Write(ex.Message) End Try End Sub I cannot get an instance of the control in the above boldfaced code after passing thru that line during debugging. It has a value of Nothing. My html code is set up as follows (shortened for brevity) within the Gridview control: <asp:TemplateField HeaderText="CustomerID"> <EditItemTemplate> <asp:DropDownList ID="ddlCustomerID" runat="server" Text='<%# Bind("CustomerID") %>' DataValueField="CustomerID" DataTextField="ContactName"></asp:DropDownList> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lblCustomerID" runat="server" Text='<%# Bind("CustomerID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> As you can see above, I have the name of the control defined in the above code in the EditItemTemplate. I am assuming that during the RowEditing event, I should be able to access the control in order to make it into a dropdownlist. During the RowUpdating event which is fired immediately after the RowEditing, I will get the SelectedValue. During non-editing, it is simply a Label control and grabs the value in the database for the CustomerID. It is only when I want to edit the row, that I cannot get an instance of the control. Can someone help me out here please? How can I get an instance of the control?
  2. You are correct. However, the following code snippet: <code> GridView1.Rows(e.RowIndex).Cells(0).Text </code> should return the row being edited in the actual gridview. The above code gives me an empty string when it should give me the value in the gridview cell. How come I am getting an empty string value for the gridview cell?
  3. In my page_load event, I have the following code: <code> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try If Not Page.IsPostBack Then BindGrid() Else GridView1.DataSource = DirectCast(Session.Item("dtCustomers"), DataTable) End If Catch ex As Exception Response.Write(ex.Message) End Try End Sub </code> While debugging, I have the following in the Immediate Window after the postback: ?GridView1.Rows.Count 10 Once I clicked the Edit button, it fired the RowEditing event which I have the following code: <code> Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing GridView1.EditIndex = e.NewEditIndex GridView1.DataBind() End Sub </code> Right at the End Sub, I had another breakpoint to examine the rows in the gridview to make sure they were still there as follows: ?GridView1.Rows.Count 10 My html of the gridview looks like this: <code> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"> <Columns> <asp:CommandField ShowEditButton="True" /> <asp:TemplateField HeaderText="CustomerID" SortExpression="CustomerID"> <ItemTemplate> <asp:HyperLink ID="hylCustomerID" runat="server" Target="_blank" Text='<%# Bind("CustomerID") %>'></asp:HyperLink> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" /> <asp:BoundField DataField="ContactName" HeaderText="ContactName" SortExpression="ContactName" /> <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" /> <asp:BoundField DataField="Address" HeaderText="Address" /> <asp:BoundField DataField="City" HeaderText="City" /> <asp:BoundField DataField="Region" HeaderText="Region" /> <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" /> <asp:BoundField DataField="Country" HeaderText="Country" /> <asp:BoundField DataField="Phone" HeaderText="Phone" /> <asp:BoundField DataField="Fax" HeaderText="Fax" /> </Columns> </asp:GridView> </code> Inside the RowUpdating event, I have the following code (which was shortened for brevity): <code> Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating Dim dtCustomers As New DataTable Try Dim dr As DataRow = dtCustomers.NewRow dr.Item("CustomerID") = GridView1.Rows(e.RowIndex).Cells(0).Text dr.Item("CompanyName") = GridView1.Rows(e.RowIndex).Cells(1).Text ........ dtCustomers.Rows.Add(dr) dtCustomers.Rows(0).SetModified() Dim cls1 As New Class1 Dim intRecdsAffected As Int16 = cls1.UpdateCustomer(dtCustomers) cls1 = Nothing GridView1.EditIndex = -1 BindGrid() Catch ex As Exception Response.Write(ex.Message) End Try End Sub </code> When I try to examine the following line of code in the above event "GridView1.Rows(e.RowIndex).Cells(0).Text", I get an empty string. Note below: ?gridview1.Rows(e.RowIndex).Cells(1).Text "" ?gridview1.Rows(e.RowIndex).Cells(0).Text "" ?gridview1.Rows(e.RowIndex).Cells(2).Text "" ?gridview1.Rows(e.RowIndex).Cells(3).Text "" ?gridview1.Rows(e.RowIndex).Cells(4).Text "" ?gridview1.Rows(e.RowIndex).Cells(5).Text "" ?GridView1.Rows.Count 10 Notice that I still have the 10 records in the gridview count at this point. I am not using any DataSource controls, so I can't use the "NewValues" property of the gridview. How can I properly retrieve the values inside the grid at this point? It seems very simple, but I am obviously missing something here.
  4. I've used dyanamic sql before to execute a sproc, but the above sproc will get executed thousands of times with one shot (see above). The dynamic option, I believe is not possible, because all the values (for the insert), will change on every iteration of executing the sproc.
  5. btw, the "hard coded" stored procedure (the one with the table name specified in it) is used with the ado.net 2.0 bulk insert capability (by setting the UpdateBatchSize to a specified amount other than 1). The dataset associated with the dataadapter, then does all the inserts at one shot (rather than calling the sproc numerous times 1 by 1 for each record). I just need to find a way for the sproc to recognized the dynamic table name I'm passing down to it for the insert.
  6. I'm trying to insert data into a table that was created dynamiclly. Data will be inserted into several of these types of tables. I tried to substitute the tablename as a parameter, but got the following error when I tried to execute the query: "Invalid object name '@CDRTableName'. Here is my stored procedure. Notice I included the periods for brevity: ALTER PROCEDURE [dbo].[insertCDRSearchResults] ( @BatchName varchar(50), . . . @CDRTableName varchar(20) ) AS INSERT INTO [@CDRTableName] ([batchName], ..., [CDR_Version]) VALUES (@BatchName, ..., @CDR_Version); If I obviously hard code the parameter @CDRTableName, it works just fine. How can I successfully construct the stored procedure in order to use the correct table name?
  7. I'm trying to enable the Service Broker for Sql Server 2005 because I want to be able to use a SqlDependency object. I ran the following query to see if my local sql server service broker was enabled: SELECT is_broker_enabled FROM sys.databases WHERE name = 'dbname'; It came back with a value of 0 (which means it is not enabled). I tried executing the following sql command to enable it: ALTER DATABASE dbname SET ENABLE_BROKER; The query has been running for over 5 mins and just keeps spinning (should it take this long to enable the Service brfoker), so I cancel it. I even try to issue the command to see if the service broker is enabled after I cancel the query and it is not enabled. How can I properly enable the Service Broker?
  8. I need to be able to access a file via a network path using the TextFieldParser object. I have the following code: <code> Dim tfParser As New TextFieldParser(\\servername\e\April_CDR_Search\0423\filename.csv) </code> I get the error that the file can't be found, when I know it is there. When I change it to my local drive (with C:\ as the prefix, it works fine). Is there something else I need to include in order for the TextFieldParser object to find the file on the network drive?
  9. scrolling textbox Thanks. That worked fine!
  10. Yes, that works fine... I should have thought about that one... Is there any way to make the textbox automatically scroll down while the lines are being written out? Since I have this form running on a thread, I can't readily move the scroll bar down to take a look at the line. It would also be a lot easier if it would just automatically scroll.
  11. I'm using Windows Forms 2.0 (Visual Stduio 2005) and cannot get characters within the textbox to scroll. I need displays coming out because it is a batch process and need to allow operators of the app to view the messages. I have the following code which I want to basically have show up in the window like so: line1 line 2 etc. <code> TextBox1.Text = ControlChars.CrLf & "Retrieving Search Definitions along with their respective Search Criteria." 'do some processing TextBox1.Text = ControlChars.CrLf & "Retrieved Search Definitions along with their respective Search Criteria." </code> I have the above type of code in several places in my app. Every time the textbox gets assigned a value, I perform the "Application.DoEvents()" method. It's being written to the textbox, but is not available in the view. When another message comes along, it seems like it doesn't write it underneath the previous one, although other messages are coming out. It simply writes to the very first line in the textbox again. I have the following pertinent properties set up for my textbox: AcceptsReturn = True AcceptsTab = True Enabled = True Locked = False MaxLength = 0 MultiLine = True ReadOnly = True Scrollbars = Vertical Visible = True WordWrap = True How can I get the characters in the textbox to appear underneath one another?
  12. When trying to create a DB diagram on my local SQL Server 2005 db, I get the following error: cannot insert the value null into column "diagram_id" I have searched the web and can't seem to find anything on this. I just simply drag one table from my local db onto the diagram windows and try to Save it and that's what I get. I'm able to save diagrams on a networked SQL Server. Does anybody know how I can resolve this issue?
  13. I'm wondering if somebody could help me resolve the infamous ""Object reference not set to an instance of an object." when I try to execute the following: I have a class like the following: Partial Public Class BinaryTreeSrchCrit Private intFldNum As Integer Private strSrchValue As String Private strOperator As String Private intSrchID As Integer Private intGrpIdx As Integer Private intPropIdx1 As Integer Private intPropIdx2 As Integer Private strLogicalOperator As String Private intRelIdx As Integer Private blnTrVal As Boolean Private strLRNode As String Private tnUlink As BinaryTreeSrchCrit 'top node of the tree Private tnLlink As BinaryTreeSrchCrit 'left node of the tree Private tnRlink As BinaryTreeSrchCrit 'right node of the tree Public Property FldNum() As Integer Get Return intFldNum End Get Set(ByVal Value As Integer) intFldNum = Value End Set End Property Public Property SrchValue() As String Get Return strSrchValue End Get Set(ByVal Value As String) strSrchValue = Value End Set End Property . . . In my app, I have the following code to try and populate the class: Dim btSrchCrit(tblSrchCrit.Rows.Count - 1) As BinaryTreeSrchCrit For i = 0 To tblSrchCrit.Rows.Count - 1 If Not tblSrchCrit.Item(i).IsFldNumNull Then btSrchCrit(i).FldNum = tblSrchCrit.Item(i).FldNum End If If Not tblSrchCrit.Item(i).IsGrpIdxNull Then btSrchCrit(i).GrpIdx = tblSrchCrit.Item(i).GrpIdx End If If Not tblSrchCrit.Item(i).IsLogicalOperatorNull Then btSrchCrit(i).LogicalOperator = tblSrchCrit.Item(i).LogicalOperator End If If Not tblSrchCrit.Item(i).IsPropIdx1Null Then btSrchCrit(i).PropIdx1 = tblSrchCrit.Item(i).PropIdx1 End If If Not tblSrchCrit.Item(i).IsPropIdx2Null Then btSrchCrit(i).PropIdx2 = tblSrchCrit.Item(i).PropIdx2 End If btSrchCrit(i).RelIdx = tblSrchCrit.Item(i).RelIdx btSrchCrit(i).SrchID = tblSrchCrit.Item(i).SrchID If Not tblSrchCrit.Item(i).IsSrchValueNull Then btSrchCrit(i).SrchValue = tblSrchCrit.Item(i).SrchValue End If If Not tblSrchCrit.Item(i).Is_OperatorNull Then btSrchCrit(i)._Operator = tblSrchCrit.Item(i)._Operator End If Next It's giving me the error on the above line: btSrchCrit(i).FldNum = tblSrchCrit.Item(i).FldNum The following is from my debugging session: btSrchCrit {Length=1} clsParseCDR.BinaryTreeSrchCrit() (0) Nothing clsParseCDR.BinaryTreeSrchCrit btSrchCrit(i) Nothing clsParseCDR.BinaryTreeSrchCrit i 0 Short As you can see, there is 1 btSrchCrit object created (since all I have in this case is one record coming into my function). The 0th index is Nothing. This is why the error is happening, but I don't know how to resolve it. There is a value in "tblSrchCrit.Item(i).FldNum" before it tries to assign it to the property in the array. After creating an index (Dim btSrchCrit(tblSrchCrit.Rows.Count - 1) As BinaryTreeSrchCrit), I thought that the 0th entry in the array would not be Nothing. You can't create arrays with a "New" keyword. Can somebody please tell me how I can resolve this issue? Thanks so much....
  14. After even going into the options and setting the Compatability level to 90, I detached and then reattached the db. I even took it offline, then back again online. I am still getting the same error msg..... What do I need to do just to be able to use the Diagram support? This is so frustating..... :mad:
  15. For some reason, when I try to access a database diagram on our new 2005 SQL Server, I get the following error msg: "Database diagram support objects cannot be installed because this database does not have a valid owner" It then goes on to instruct me to either use Properties > Files or ALTER AUTHORIZATION to change the database owner. Well, I've done that - and it clearly shows that there is an owner of the database, but even if I log in as that owner, the error msg continues to come up everytime I try to access Diagrams. I found a post to run the following stored procedure which will set the sql server compatability level: EXEC sp_dbcmptlevel database_name, 90 After running that in the query window of Management Stduio, I get the following msg below on the Messages tab: "DBCC execution completed. If DBCC printed error messages, contact your system administrator." I then try to create a new diagram again, and I get the same initial error (at the top of this post). What do I need to do in order to create a DB diagram?
  16. Is there a way to expose the SqlDataAdapter within a TableAdapter as a Public property even after re-generating the TableAdapter? I can't use TableAdapters, because they don't expose the SqlDataAdapter as a Public property since I need to pass down the DataAdapter to a separate DB I/O method. Not a generated DB I/O method within the TableAdapter. I'm forced to use the Component Designer and create a SqlDataAdapter like I have been doing in VS.Net 2003. The following code is generated when creating a TableAdapter: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _ Private ReadOnly Property Adapter() As System.Data.SqlClient.SqlDataAdapter Get If (Me._adapter Is Nothing) Then Me.InitAdapter() End If Return Me._adapter End Get End Property <System.Diagnostics.DebuggerNonUserCodeAttribute()> _ Public Property Connection() As System.Data.SqlClient.SqlConnection Get If (Me._connection Is Nothing) Then Me.InitConnection End If Return Me._connection End Get Set Me._connection = value If (Not (Me.Adapter.InsertCommand) Is Nothing) Then Me.Adapter.InsertCommand.Connection = value End If If (Not (Me.Adapter.DeleteCommand) Is Nothing) Then Me.Adapter.DeleteCommand.Connection = value End If If (Not (Me.Adapter.UpdateCommand) Is Nothing) Then Me.Adapter.UpdateCommand.Connection = value End If Dim i As Integer = 0 Do While (i < Me.CommandCollection.Length) If (Not (Me.CommandCollection(i)) Is Nothing) Then CType(Me.CommandCollection(i),System.Data.SqlClient.SqlCommand).Connection = value End If i = (i + 1) Loop End Set End Property Notice that you can set the Connection property as a Public property in the DataSet Designer, but there is no such option for the DataAdapter. Just for kicks, I modified the code to make the DataAdapter a Public property (changed the Boldfaced Private to Public above), and was able to access it in code as follows: Dim ta As New DataSet2TableAdapters.CustomersTableAdapter Dim dst As New DataSet2 DataAccess.Data.SQLServerDataAccess.GetSQLData(ta.Connection, [b]ta.Adapter[/b], dst) The Adapter contains the associated Command objects and passes it down to the DB I/O layer performing the appropriate FILL or UPDATE command. In this case, it's obviously the FILL command. So, Microsoft should have made an option not to tie the TableAdapter to DB I/O code from within the generated code itself. They also should include an option to make the generated DataAdapter a Public object (as seen above). I hope this gets fixed in a service pack release. Barring this, does anybody know how I can consistently make the DataAdapter appear as a Public object?
  17. Thanks, that was it!
  18. I'm using the new TextFieldParser class and want to find out how to use the "Find" method of the Array object after I parse multiple fields of a line into a string array. Here is the code: Private Sub ParseData2() Dim fields As String() Dim parser As New TextFieldParser("c:\epp\test.txt") Try parser.SetDelimiters(";") parser.TrimWhiteSpace = True While Not parser.EndOfData ' Read in the fields for the current line fields = parser.ReadFields() Dim str As String = Array.Find(fields, AddressOf ProductGT11) End While Catch ex As Exception Throw ex End Try End Sub Private Shared Function ProductGT11(ByVal p As String()) As Boolean 'code here will do the find End Function The "AddressOf ProductGT11" inside the ParseData2 sub is giving me a compile time error: Method 'Private Shared Function ProductGT11(p() as string) as Boolean does not have the same signature as delegate 'Delegate Function Predicate(Of T)(obj as String) As Boolean How can I correct his?
  19. I have the following problem in my programming scenario: Someone clicks on a link to take a Math Placement Test which opens a Math Placement Test pop-up after entering the password and submitting. They close the pop-up window without taking the test, and then click on any other link. They then click on the back button on the browser and it takes them back to the previous page, and the closed pop-up window pops up again. How can I clear the browser history (in the code-behind) to avoid this problem?
  20. I'm getting the above error when running through my code. I know at desgin time what the problem is, but at run time I'm changing the MasterPage to use with a specific aspx page in the Page_PreInit event. If I could solve the design time compile error, I'm hoping it will fix the run-time error. I have code in my code-behind file that looks like the following: Public WithEvents objMaster As MasterPage 'Get a reference to the master page objMaster = DirectCast(Me.Master, MasterPage) 'Add the section and get a treeview back objMaster.AddCustomSection(2, "Folders") Protected Sub Page_PreInit1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit If Session.Item("EPPMasterPageFile") IsNot Nothing Then Me.MasterPageFile = Convert.ToString(Session.Item("EPPMasterPageFile")) Else Me.MasterPageFile = "~/MasterPage.master" End If End Sub The boldfaced line above has a design time compile error in it.stating that "AddCustomeSection is not a member of 'System.Web.UI.MasterPage". When I have the MasterPageFile property of the aspx page at design time set to a master page (which is contained inside the Sessin variable), "MasterPageFile="~/Platform/EPP/Portfolio/EPPMasterPage.master", that's when the compile error occurs. I have the following section inside the above masterpage: Public Sub AddCustomSection(ByVal Index As Integer, ByVal Title As String) Dim objCustomSection As New CustomSection objCustomSection.Index = Index objCustomSection.Title = Title objCustomSections.Add(objCustomSection) End Sub As you can see, the sub is public and should be able to be seen by my code behind file with the intellisense. Now, bearing the above in mind, when I change the MasterPageFile property of the aspx page at design time to the main master page (on the root of the website), with the same code above (the main one has the Sub in it as well), I do not get a design time compile error! The application runs and changes the master pages successfully with no problem, except when I click on a link that needs the code above (inside the masterpage, which is not on the root). Note that these masterpages are not related, and they are not in a parent/child relationship. Does anybody know what the problem is?
  21. I tried using that, but am consistently getting a "system.io.filenotfound" execption even though when I take that path string and put it inside internet explorer, the file comes up. So, I am sure the file exists. Is the Shell command strictly for Windows or can it work on the web. If it supposedly can work on the web, it won't work with what I'm doing.....
  22. I'm trying to start an IE process so that the browser can launch the proper application after bringing the file into the browser in order to bring up the associated file. code is as follows: <code> Process.Start("IExplore.exe", "C:\Temp\myFile.txt") </code> The file "C:\Temp\myFile.txt" exists on my local hard drive. It's a small text file. No error occurs after the statement is executed. Another application doesn't for the file doesn't pop up at all. How can I get the proper application to launch? What am I missing?
  23. I added a recursive "FindControl" method since the butoon is inside of a placeholder control. This did the trick just fine.
  24. I'm trying to get an instance of a Delete button on my webform in order to display a warning msg to the user. I've done this type of thing several times for a button inside a datagrid for a user confirm to delete a particular record. this webform has no datagrid. Simply a delete button. However, the form is set up as having multiple placeholder controls depending upon which functionality is initially selected. The following is the html within my webform: <asp:Button id="btnDelete" Text="Delete" runat="server" class="eppbutton"/> The following info is in my code-behind: ElseIf Request.QueryString.Item("iManage") = 3 Then 'Delete plcAddFile.Visible = False plcAddFolder.Visible = False plcDelete.Visible = True plcEdit.Visible = False plcPublish.Visible = False plcCustomize.Visible = False plcContact.Visible = False 'Set up a delete confirmation Dim btnDeleteFilefolder As Button btnDeleteFilefolder = DirectCast(Me.FindControl("btnDelete"), Button) btnDeleteFilefolder.Attributes.Add("onclick", "return getdelconfirm();") While debugging, I get the following instance of the Delete button from within the Auto window: - btnDelete {Text = "Delete"} System.Web.UI.WebControls.Button As you can see, the ID of the button is availabile. I'm getting an "Object not set to an instance of an object" on the boldfaced line of code above. What am I doing wrong here where I can't get an instance of this object?
×
×
  • Create New...