Jump to content
Xtreme .Net Talk

gtjr92

Members
  • Posts

    14
  • Joined

  • Last visited

gtjr92's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. got it Figured out my theme problem, i was not inheriting the basepage class to the rest of my pages DUH!! Thanks for your help!
  2. half way there changing the selected index changed event solved the dropdown list problem. However the theme is still only being applied to one page, and not site wide. If I manually change the them in the webconfig file the theme is applied properly so i must be missing something else in my code.
  3. Re Ok commented this out and it still works the same so i guess it is not neccessary. when i comment out the server.transfer i click on the drop down list it changes to the wrong theme. IE if i click on a "green" them it changes to the red theme, etc In all scenarios the theme is never applied to any page except the page that has the ddl. Other ideas?? Thanks
  4. re I tried removing the Server.Transfer(Request.FilePath) that does make a change, but not the one i desire. With this change when i click on the drop down list it changes to the wrong theme. IE if i click on a "green" them it changes to the red theme, etc I will try taking out the drop down events you suggested in the morning thanks
  5. I am trying to set up themes in ASP.Net 2.0 I set up an page load event that grabs the themes by checking the app_themes folder. Added some events for my dropdown list. There are 2 issues i am having 1. When i choose a theme from my dropdown it changes my themes. However when I choose the theme from the dropdown and the page postback the selected item is the first item in the list and not the theme I selected. The theme of the page changes, but the dropdown just defaults back to the first item in list. I am sure this has something to do with what I have the selected text/value equal too see code below. 2. The other thing I can't figure out is my session is not being saved. After I choose the theme if i click on a link to another page no theme is applied to other pages on the site, view state is enabled for my dropdown list -ddlthemes See code below Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then 'get app themes folders Dim themes As String() = IO.Directory.GetDirectories(Request.PhysicalApplicationPath & "App_Themes") ' 'add themes to dropdown list ddlThemes.Items.Clear() For Each theme As String In themes ' add name not path ddlThemes.Items.Add(theme.Substring(theme.LastIndexOf( "\") + 1)) Next End If End Sub 'Dropdown list events Protected Sub ddlThemes_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles ddlThemes.DataBound ddlThemes.SelectedItem.Text = Page.Theme End Sub Protected Sub ChangeTheme_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ddlThemes.SelectedIndexChanged Session.Add("MyTheme", ddlThemes.SelectedItem.Text) Server.Transfer(Request.FilePath) End Sub 'basepage class inherited into above page. Imports Microsoft.VisualBasic Imports System Imports System.Data Imports System.Configuration Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Public Class BasePage Inherits System.Web.UI.Page Protected Overrides Sub OnPreInit(ByVal e As EventArgs) MyBase.OnPreInit(e) If Session("MyTheme") Is Nothing Then Session.Add("MyTheme", "Black") Page.Theme = (CType(Session("MyTheme"), String)) Else Page.Theme = (CType(Session("MyTheme"), String)) End If End Sub End Class
  6. Finally FINALLY I got it for whatever reason that if statement would not execute in the computesum sub so I created a hidden field in the compute sum sub, I drew the tithecountsumvalue from another label into the hidden field, rather than use the tithecountsum. I then created a new sub and ran that on the gridview -onprerender Worked like a charm! If there is an easier way that someone knows how to do this feel free to comment but this worked after the tons of things i tried! Sub ComputeAvg(ByVal Sender As Object, ByVal e As EventArgs) If Not lbxWkid.SelectedIndex = -1 Then Dim lbxValue As Double = CDbl(lbxWkid.SelectedItem.Text) Dim TitheVal As String = hidTithesum.Value TitheAvg = TitheVal / lbxValue lblAvg.Text = String.Format("{0:c}", TitheAvg)
  7. Ok I figured out some more If I take the if statement and make it a seperate sub and execute that sub on listbox selected change like this (I am using asp.net 2.0) Partial Class YearlyOff Inherits System.Web.UI.Page Dim TitheCountSum As Double = 0 Dim EducationCountSum As Double = 0 Dim MissionCountSum As Double = 0 Dim SpecialCountSum As Double = 0 Dim GiftValueCountSum As Double = 0 Dim OfferingTotal As Double = 0 Dim DepositTotal As Double = 0 Dim Weekid As Double = 0 Dim Datewk As Date Dim TitheAvg As Double = 0 Sub ComputeAvg(ByVal Sender As Object, ByVal e As EventArgs) If Not lbxWkid.SelectedIndex = -1 Then Then Dim lbxValue As Double = CDbl(lbxWkid.SelectedItem.Text) TitheAvg = TitheCountSum / lbxValue lblAvg.Text = lbxWkid.SelectedValue & String.Format("{0:c}", TitheAvg) End If End Sub My lblavg.text gets $0.00 this is because tithecount sum is a default value of zero before it evals the sumoftithe field. My eval tithcountsum evals that field in another sub. I even tried to create a new if statement within the same sub and nothing happens like my previous post. Here is all of my code for the sub i originally reffered too This sub is run on rowdatabound Public Sub ComputeSum(ByVal sender As Object, ByVal e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then 'ListItemType.item = ListItemType.AlternatingItem Then 'Snip out the Total of Each Row & Column Datewk = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "Date")) Weekid = Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "WEEK")) TitheCountSum += Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "SumofTithe")) EducationCountSum += Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "SumofEducation")) MissionCountSum += Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "SumofMissions")) SpecialCountSum += Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "SumOfSpecial")) 'GiftValueCountSum += Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "Gift_Value")) OfferingTotal = TitheCountSum + MissionCountSum + SpecialCountSum DepositTotal = TitheCountSum + MissionCountSum + SpecialCountSum + EducationCountSum 'lbxValue += Convert.ToDouble(lbxWkid.SelectedValue) 'Label2.Text = "Tot Offering* " & String.Format("{0:C}", OfferingTotal) LblOfferingTot.Text = "Total Offering* " & String.Format("{0:C}", OfferingTotal) LblTithe.Text = "Total Tithe: " & String.Format("{0:C}", TitheCountSum) LblEducation.Text = "Total Education: " & String.Format("{0:C}", EducationCountSum) LblMissions.Text = "Total Missions: " & String.Format("{0:C}", MissionCountSum) LblSpecial.Text = "Total Special: " & String.Format("{0:C}", SpecialCountSum) LblDepositTot.Text = "Total Deposit* " & String.Format("{0:C}", DepositTotal) Lblstar.Text = "Total Offering =Tithe Total + Mission Total + Special Total" LblDeposit.Text = "Total Deposit=Tithe Total + Mission Total + Special Total + Education Total" ElseIf e.Row.RowType = DataControlCellType.Footer Then e.Row.RowType = DataControlCellType.Footer e.Row.Cells.Item(3).Text = "Total Ti: " & String.Format("{0:C}", TitheCountSum) e.Row.Cells.Item(4).Text = "Total Ed: " & String.Format("{0:C}", EducationCountSum) e.Row.Cells.Item(5).Text = "Total Mis: " & String.Format("{0:C}", MissionCountSum) e.Row.Cells.Item(6).Text = "Total SP: " & String.Format("{0:C}", SpecialCountSum) [color=DarkRed]'I had the statment I am having trouble with inside this if statment as an ElseIF Like this[/color] ElseIf Not lbxWkid.SelectedIndex = -1 Then Then Dim lbxValue As Double = CDbl(lbxWkid.SelectedItem.Text) TitheAvg = TitheCountSum / lbxValue lblAvg.Text = String.Format("{0:c}", TitheAvg) End If [color=DarkRed]'and I Also tried as a seperated If statement in the same sub. Neither of these gives me a value in my lblavg.text[/color] If Not lbxWkid.SelectedIndex = -1 Then 'ElseIf Not lbxWkid.SelectedItem Is Nothing Then Dim lbxValue As Double = CDbl(lbxWkid.SelectedItem.Text) TitheAvg = TitheCountSum / lbxValue lblAvg.Text = String.Format("{0:c}", TitheAvg) End If End Sub
  8. no go... Ok here is everthing I have tried and the results... ElseIf Not lbxWkid.SelectedItem Is Nothing Then Page loads, when I click an item the page postback but nothing shows up in the lblavg text box No errors are thrown. If Not lblWkik.SelectedIndex = -1 Then Page loads, when I click an item the page postback but nothing shows up in the lblavg text box No errors are thrown. ElseIf lbxWkid.SelectedValue <> "" Then Page loads, when I click an item the page postback but nothing shows up in the lblavg text box No errors are thrown. If I do this ElseIf lbxWkid.SelectedIndex > -1 Then ElseIf IsNumeric(lbxWkid.SelectedValue) Then Page loads, when I click an item the page postbacks but nothing shows up in the lblavg text box No errors are thrown When I try this ElseIf lbxWkid.SelectedItem.Text > 0 Then Object reference not set to an instance of an object. If I try this ElseIf cdbl(lbxWkid.SelectedValue) > 0 Then I get Input string was not in a correct format. Here is my "then" code which I know works because if I take out the if statements and change titheavg = tithecountsum / 20 my lblavg shows the value of titheavg. Dim lbxValue As Double = CDbl(lbxWkid.SelectedItem.Value) TitheAvg = TitheCountSum / lbxValue lblAvg.Text = String.Format("{0:c}", TitheAvg) This is for asp.net 2.0 I don't think that matters though.
  9. re: It throws the error for this line ElseIf lbxWkid.SelectedItem.Selected = True Then Here is the full error System.NullReferenceException was unhandled by user code Message="Object reference not set to an instance of an object." Source="App_Web_xi7tdrfw" StackTrace: at YearlyOff.ComputeSum(Object sender, GridViewRowEventArgs e) in H:\ASPNET20\WebSites\GBCTithe\YearlyOff.aspx.vb:line 57 at System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e) at System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) at System.Web.UI.WebControls.DataBoundControl.PerformSelect() at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at System.Web.UI.WebControls.GridView.DataBind() at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  10. tried that... Tried that I got object reference not set to an instance of an object ElseIf lbxWkid.SelectedItem.Selected = True Then Dim lbxValue As Double = Convert.ToDouble(lbxWkid.SelectedItem.Value) TitheAvg = TitheCountSum / lbxValue lblAvg.Text = String.Format("{0:c}", TitheAvg) ElseIf lbxWkid.SelectedItem.Selected = False Then End If
  11. I am trying to get an average of some row totals. I know how to do that, but my average depends on what value is selected in my listbox(lbxwkid) Conversion from string "" to type 'Double' is not valid. for this line ElseIf lbxWkid.SelectedValue().ToString > 0 Then HEre is my code the tithecountsum is also a double. ElseIf lbxWkid.SelectedValue().ToString > 0 Then ElseIf lbxWkid.SelectedValue().ToString > 0 Then Dim lbxValue As Double = Convert.ToDouble(lbxWkid.SelectedValue) TitheAvg = TitheCountSum / lbxValue lblAvg.Text = String.Format("{0:c}", TitheAvg)
  12. I am using asp.net 2.0 I keep getting the below errors I have a sub that looks at my gridview and then is supposed to update my database with the parameters below but I get these errors ... Value of type 'Decimal' cannot be converted to 'System.Web.UI.WebControls.Parameter'. for this line "dsoTithe.UpdateParameters.Item("@Titheparam") = CDec("@Titheup")" If I try iy this way dsoTithe.UpdateParameters.Item(CInt("@TRidparam") = CInt("@id")) Then I get "Property access must assign to the property or use its value." HEre is the rest of my code for this Sub Updatedb(ByVal sender As Object, ByVal e As EventArgs) Dim dgi As GridViewRow For Each dgi In GridView1.Rows ' Read in the Primary Key Field Dim id As Int32 = (GridView1.DataKeys(dgi.RowIndex).Value.ToString()) Dim Titheup As Decimal = CType(dgi.FindControl("TxtTithe"), TextBox).Text dsoTithe.UpdateParameters.Item("@Titheparam") = CDec("@Titheup") dsoTithe.UpdateParameters.Item(CInt("@TRidparam") = CInt("@id")) dsoTithe.UpdateParameters.Clear() dsoTithe.Update() Next End Sub <asp:AccessDataSource ID="dsoTithe" runat="server" DataFile="~/App_Data/tithe/GBCTITHE.MDB" SelectCommand="SELECT [Weeks_Date], [People_ID], [Name], [Tithe], [Education], [Missions], [special], [Gift_Item], [Gift_Value], [WkID], [TRID] FROM [TblCombine] WHERE ([WkID] = ?)" UpdateCommand="UPDATE [Tithe] SET [Tithe]=? Where [trid]=?"> <UpdateParameters> <asp:Parameter Name="Titheparam" Type="Decimal" /> <asp:Parameter Name="Tridparam" Type="Int32" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="lbxWeeks" DefaultValue="1" Name="WkID" PropertyName="SelectedValue" Type="Double" /> </SelectParameters> </asp:AccessDataSource>
  13. Re: that is here <form id="form2" runat="server"> <div> <asp:AccessDataSource ID="dsoTithe" runat="server" DataFile="~/App_Data/tithe/GBCTITHE.MDB" SelectCommand="SELECT [Weeks_Date], [People_ID], [Name], [Tithe], [Education], [Missions], [special], [Gift_Item], [Gift_Value], [WkID], [TRID] FROM [tithe] WHERE ([WkID] = ?)" UpdateCommand="UPDATE [Tithe] SET [Tithe]=? Where [trid]=?"> <UpdateParameters> <asp:Parameter Name="Titheparam" Type="Decimal" /> <asp:Parameter Name="Tridparam" Type="Int32" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="lbxWeeks" DefaultValue="1" Name="WkID" PropertyName="SelectedValue" Type="Double" /> </SelectParameters> </asp:AccessDataSource>
  14. This is for an asp.net 2.0 site, but I think the VB should be similiar. I am using an access datasource, I set up a sub update db that checks the textboxes and updateds the Database. Basically I want a fully editable Gridview. i think Sqlcommandevent args is what i need I believe sql and access share some properties. Here is my error, my code is below that. I understand(i think) why i am getting the error but I am not sure how to correct it. BC30408: Method 'Public Sub Updatedb(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEven tArgs)' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'. Source Error: Line 126: <div style="z-index: 103; left: 307px; width: 65px; position: absolute; top: 653px; Line 127: height: 28px"> Line 128: <asp:Button ID="Button1" runat="server" Text="Update Tithe" OnClick=Updatedb /></div> Line 129: <%-- <asp:AccessDataSource ID="Titheupdate" runat="server" DataFile="~/App_Data/tithe/GBCTITHE.MDB" Line 130: UpdateCommand="UPDATE [Tithe] SET [WkID] = ?, [People_ID] = ?, [Tithe] = ?, [Education] = ?, [special] = ?, [Missions] = ?, [Gift_Item] = ?, [Gift_Value] = ? WHERE [TRID] = ?"> Sub Updatedb(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs) Dim dgi As GridViewRow For Each dgi In GridView1.Rows 'Read in the Primary Key Field Dim id As Integer = (GridView1.DataKeys(dgi.RowIndex).Value.ToString() ) Dim Titheup As Decimal = CType(dgi.FindControl("TxtTithe"), TextBox).Text e.Command.Parameters("@Titheup").Value = e.Command.Parameters("@TitheParam").Value e.Command.Parameters("@id").Value = e.Command.Parameters("@Tridparam").Value e.Command.Parameters.Remove(e.Command.Parameters("@TitheParam")) e.Command.Parameters.Remove(e.Command.Parameters("@ID")) dsoTithe.Update() Next End Sub 'I tried it this way too.. 'Same type of error for this too Sub Updatedb(ByVal sender As Object, ByVal e As AccessDataSourceView) Dim dgi As GridViewRow For Each dgi In GridView1.Rows 'Read in the Primary Key Field Dim id As Integer = (GridView1.DataKeys(dgi.RowIndex).Value.ToString() ) Dim Titheup As Decimal = CType(dgi.FindControl("TxtTithe"), TextBox).Text 'e.UpdateParameters. e.UpdateParameters("@Titheup") = e.UpdateParameters("@TitheParam") e.UpdateParameters("@id") = e.UpdateParameters("@Tridparam") e.UpdateParameters.Clear() dsoTithe.Update()
×
×
  • Create New...