Jump to content
Xtreme .Net Talk

wsyeager

Avatar/Signature
  • Posts

    140
  • Joined

  • Last visited

Everything posted by wsyeager

  1. I did the following to resolve the problem: On the webserver with the problem, run this command: aspnet_regiis.exe -c from [windows]\microsoft.net\framework\[version] It copies the correct files for the version of ASP.NET you are running into each domain defined in IIS.
  2. I have a simple button and textbox on a webform with a RequiredFieldValidator tied to the textbox control. The problem is that a postback never occurs on the webform by clicking the button even when I have something inside the textbox. If I don't have the validator control on the webform, then the button clicked event gets fired (causing the postback - I have a breakpoint set in the Button.Clicked event of the button on the webform). The CausesValidation property of the button is set to True, but I have something inside the textbox and it still doesn't postback. I thought that a postback will NOT occur only if there is some kind of validation or required error with the control. In this case, something is inside the textbox, so how come the postback doesn't occur? Does anyone know what the problem is with this?
  3. I'm using connection pooling (0 min/100 max) in an asp.net web application. All users log in using the same connectionstring. Is it prudent, for instance, to close and dispose of my connection after a database update takes place which I normally do when I'm not using connection pooling?
  4. I'm registering a startup script in my "page load" event. Everything works fine when I run it locally, but when it's deployed to the webserver, it doesn't execute the javascript which is inside a ".js" file (on the root directory of the website). Here is the HTML where I have the javascript function to execute: <code> <TD style="HEIGHT: 23px"> <input name="txtEnding" type="text" value="100" id="txtEnding" tabindex="24" onChange="CalculateTotalMileage();" style="width:96px;" /></TD> </code> Here is the code in my code behind page: <code> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RegisterScripts() . . . Private Sub RegisterScripts() txtMileageBeginning.Attributes.Add("onChange", "CalculateTotalMileage();") txtEnding.Attributes.Add("onChange", "CalculateTotalMileage();") ddlDispatchInfo.Attributes.Add("onChange", "EnableDispatchInfoOther();") If (Not IsClientScriptBlockRegistered("PageStartupJScript")) Then RegisterClientScriptBlock("PageStartupJScript", "<script language=""javascript"" src=""/EMSAssist/ClientFunctions.js""></script>") End If End Sub </code> Why isn't the web application recognizing the javascript functions when it's deployed to the webserver?
  5. After the data is bound to the grid, the user selects the rows that they want processed. The rows that they want processed can either be updated or not from the grid. There is now way for me to know before hand which rows the user checkedc until a postback occurs. After the user hits a Submit button, I then grab the dataset back from viewstate and begin processing the appropriate checked rows. Is there a property somewhere where I can specify where the ViewState is to be saved (eg: on the client, etc)? If I can't save it in viewstate on the server (because of poor performance), maybe I can then try to save it in SessionState on a SQL Server Database via the web.config file...
  6. I have a grid that I databind with a strongly typed dataset which contains thousands of records retrieved from a database. After the dataset is retrieved from the database, I place it in viewstate. I need to do this because of the following: A user is allowed to check "x" amount of rows on the grid and submit those records (which causes a postback) to the database for updating. At this point, I grab the dataset from viewstate and simply process those records from the appropriate event. The records in the dataset are processed depending on which rows were checked on the grid. The syncing of rows in the grid to the dataset is exactly the same which is expected. However, based on the dataset being large, this can reduce performance because of the dataset which was placed in viewstate. If I don't place the dataset in viewstate and grab the records from the database again performing the databind, the rows that the user checked will be lost. Even if I somehow save the rows that were checked via viewstate in between postbacks and apply that to the dataset after the databind, the application runs the risk of the rows being out of sync on the datagrid to the dataset, because some other user could have processed those rows. If custom paging is implemented on the grid, I suppose this would reduce the work load on the data in viewstate which defintely would be acceptable. If not using custom paging, this scenario would still exist. Can somone please shed some light on whether or not my thinking is correct? How would one deal with this scenario?
  7. I forgot to include a check for ItemType in my code....
  8. I have a datalist that displays the following when a web page is rendered: Community_Property: 2 | Corporation: 5 | Custodian: 10 | Individual: 138 | Joint: 82 | Tenants_By_Entirety: 0 | Tenants_In_Common: 1 | Trust: 82 Each of the text items above is a linkbutton. However, I want to disable the linkbutton if the count is zero. Hence, I have the following code in my DataList1.ItemDataBound event: Dim lblCount As Label = DirectCast(e.Item.FindControl("lblCount"), Label) Dim lbtnReg2 As LinkButton = DirectCast(e.Item.FindControl("lbtnReg2"), LinkButton) If lblCount.Text = 0 Then lbtnReg2.Enabled = False End If The first time thru, it works fine. The second time thru, I get the "Object not set to an instance of an object" err msg. I thought for every item in the datalist, this event fires. How come it works for the first record, but not subsequent records? btw, the RepeatDirection is set to Horizontal and the RepeatColumns is 5... I'd appreciate any help...
  9. datalist binding problem WhenI took away the datasource and datamember in the html and placed it in the code-behind, it worked like so: <code> DataGrid1.DataSource = dsCnts DataGrid1.DataBind() </code> I had the wrong Datasource in the HTML to begin with. However, I'm trying the same code for a DataList. I don't have any Datasource or Datamember defined in the HTML. In the HTML, I have the following: <code> <asp:DataList id="DataList1" runat="server"></asp:DataList> </code> In the code-behind, I have the following: <code> DataList1.DataSource = dsCnts DataList1.DataBind() </code> No data is displayed with the above code. What's the difference between that and the code for the datagrid using the exact same code with 1 record in the dataset? Why doesn't the DataList display?
  10. I can't bind a typed dataset to a datagrid. I've tried all kinds of things, but it just won't bind. I know I'm missing something! Weird thing is, I've done this many, many times before with no problem! Here is my xml schema for the typed dataset: <code> <?xml version="1.0" encoding="utf-8" ?> <xs:schema id="dsNAFCounts" targetNamespace="http://tempuri.org/dsNAFCounts.xsd" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns="http://tempuri.org/dsNAFCounts.xsd" xmlns:mstns="http://tempuri.org/dsNAFCounts.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="dsNAFCounts" msdata:IsDataSet="true"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="NAFCounts"> <xs:complexType> <xs:sequence> <xs:element name="RegLit" type="xs:string" minOccurs="0" /> <xs:element name="RegCnt" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema> </code> Here is my HTML for the grid: <CODE> <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="NAFcnts.WebForm1"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> </HEAD> <body> <form id="Form1" method="post" runat="server"> <asp:datagrid id=DataGrid1 runat="server" DataMember="NAFCounts" DataSource="<%# DsNAFCounts1 %>"> </asp:datagrid></form> </body> </HTML> Here is my code-behind for the webform: <code> Imports System.Data.OleDb Public Class WebForm1 Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.DsNAFCounts1 = New NAFcnts.dsNAFCounts CType(Me.DsNAFCounts1, System.ComponentModel.ISupportInitialize).BeginInit() ' 'DsNAFCounts1 ' Me.DsNAFCounts1.DataSetName = "dsNAFCounts" Me.DsNAFCounts1.Locale = New System.Globalization.CultureInfo("en-US") CType(Me.DsNAFCounts1, System.ComponentModel.ISupportInitialize).EndInit() End Sub Protected WithEvents DsNAFCounts1 As NAFcnts.dsNAFCounts Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private dsCnts As New dsNAFCounts Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim drCnt As dsNAFCounts.NAFCountsRow = dsCnts.NAFCounts.NewNAFCountsRow drCnt.RegCnt = "90" drCnt.RegLit = "test" dsCnts.NAFCounts.AddNAFCountsRow(drCnt) DataGrid1.DataSource = dsCnts DataGrid1.DataBind() End Sub End Class </code> The following code binds a grid to an untyped dataset which works fine... Here is the html for an untyped dataset: <code> <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.vb" Inherits="NAFcnts.WebForm2"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm2</title> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body> <form id="Form1" method="post" runat="server"> <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 416px; POSITION: absolute; TOP: 224px" runat="server"></asp:DataGrid> </form> </body> </HTML> </code> Here is the code-behind for the untyped dataset: <code> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim ds As New DataSet ds.Tables.Add("test") Dim fNameColumn As DataColumn = New DataColumn fNameColumn.DataType = System.Type.GetType("System.String") fNameColumn.ColumnName = "RegCnt" ds.Tables(0).Columns.Add(fNameColumn) Dim fNameColumn2 As DataColumn = New DataColumn fNameColumn2.DataType = System.Type.GetType("System.String") fNameColumn2.ColumnName = "RegLit" ds.Tables(0).Columns.Add(fNameColumn2) ' Once a table has been created, use the NewRow to create a DataRow. Dim myRow As DataRow myRow = ds.Tables(0).NewRow() ' Then add the new row to the collection. myRow(0) = "90" myRow(1) = "test" ds.Tables(0).Rows.Add(myRow) DataGrid1.DataSource = ds.Tables(0) DataGrid1.DataBind() End Sub </code> Can someone PLEASE help me out with this? Just copy and paste the code into a project(Webform1 and Webform2 and create a dataset). When I'm debugging my code-behind in the Typed dataset module, I check the contents of dsCnts in the following line<code> DataGrid1.DataSource = dsCnts </code>, and it has 1 record in it which is what I'm expecting. When the datagrid binds the data, it doesn't show the data! Why won't the datagrid bind this data in the Typed dataset and show me the record? All it shows is just the column headings, while the Untyped test shows the column headings and the data (1 record as well).
  11. I have the following user control in my project simply for setting focus to a control: Public Class SetFocus Inherits System.Web.UI.UserControl Public Sub Focus(ByVal strClientID As String) Dim script As String = "" script = "<SCRIPT languange='JavaScript'>" & _ "document.getElementById('" & _ strClientID & "').focus();" & _ "</SCRIPT>" Page.RegisterStartupScript("focus", script) End Sub I have the following code in my HTML section of the aspx page that tries to access this user control: <%@ Register TagPrefix="YTCIWebUserControls" TagName="SetFocus" Src="../UserControls/SetFocus.ascx" %> . . . <YTCIWebUserControls:SetFocus id="SetFocus1" runat="server"></YTCIWebUserControls:SetFocus> I have the following code in my code-behind section of the aspx page that tries to access this user control: Protected ucFocus As New YTCIWebUserControls.SetFocus . . . If Not Page.IsPostBack Then ucFocus.Focus(mtbFromDate.ClientID) End If When I try and run the page, I get the following error: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 33: If Not Page.IsPostBack Then Line 34: ucFocus.Focus(mtbFromDate.ClientID) Source File: C:\Inetpub\wwwroot\EmsAssist\Reports\MemberCall.aspx.vb Line: 34 Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] YTCIWebUserControls.SetFocus.Focus(String strClientID) EmsAssist.MemberCall.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\EmsAssist\Reports\MemberCall.aspx.vb:35 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +731 However, when I don't use the user control, and implement the code from the user control in place of using the user control everything works fine as indicated below: If Not Page.IsPostBack Then Dim intRandomNbr As Integer Dim script As String = "" script = "<SCRIPT languange='JavaScript'>" & _ "document.getElementById('" & _ mtbFromDate.ClientID & "').focus();" & _ "</SCRIPT>" intRandomNbr = GenerateRandomNbr() Page.RegisterStartupScript("focus" & intRandomNbr, script) End If What am I doing wrong that the user control can't be used???
  12. Is there a way when you're building a web setup project, to change the physical directory where the web application will be installed on a web server instead of the default path of c:\inetpub\wwwroot?
  13. I have a problem executing some ASP.Net pages in a certain setup... I have a virtual directory setup on my local computer inside the wwwroot directory called EMSAssist. When I create a deployment project, the project gets placed on a test destination webserver called "www.nicemtech.com/emsassist". When I try to go back to the main menu from the following link (inside the website): "http://www.nicemtech.com/emsassist/Scheduling/Admin/MemberAdmin.aspx", it works fine without a problem... A domain name has been registered (http://www.emsassist.com) where the website will now be deployed. When I try now to go back to the main menu from the website (from the following link: "http://www.emsassist.com/Scheduling/Admin/MemberAdmin.aspx", I get the following System.Web.Httpexception error: "Cannot use a leading .. to exit above the top directory". I know this error has been caused by the following code in the aspx page that caused the error: <code> <%@ Register TagPrefix="YTCIWebUserControls" TagName="SchedulingAdminLogout" Src="../../UserControls/NCVACEMT/SchedulingAdminLogout.ascx" %> </code> It seems when executing from the test web server, it's fine (5 levels down from the root - http://www.nicemtech.com/emsassist/Scheduling/Admin/MemberAdmin.aspx). However, when executing from the actual domain name, it crashes (4 levels down from the root - http://www.emsassist.com/Scheduling/Admin/MemberAdmin.aspx). I'm explicitly stating to grab my usercontrol from the following pathname (../../UserControls/NCVACEMT/SchedulingAdminLogout.ascx), which, doesn't exist in the domain name site because of the extra "../" in my path, but is fine with my testwebsite... Is there any way for me to somehow seemlessly have the two different sites working without changing the pathname of the test site and production site to two different paths?
  14. Thanks, I'll look into that...
  15. problem executing the javascript I tried placing the following logic in my page_load event to handle the client-side jhavascript needed to add the first 2 textboxes to the total: <code> txtMileageBeginning.Attributes.Add("onChange", "ChkMileage(document.getElementById('" & txtMileageBeginning.ClientID & "'), document.getElementById('" & txtEnding.ClientID & "'), document.getElementById('" & txtTotal.ClientID & "');") txtEnding.Attributes.Add("onChange", "ChkMileage(document.getElementById('" & txtMileageBeginning.ClientID & "'), document.getElementById('" & txtEnding.ClientID & "'), document.getElementById('" & txtTotal.ClientID & "');") Dim sbChkMileage As New StringBuilder sbChkMileage.Append("<SCRIPT language='javascript'>") sbChkMileage.Append("function ChkMileage(objTextBox1, objTextBox2, objTextBox3) { ") sbChkMileage.Append("if(objTextBox1.value.length > 0 && objTextBox2.value.length > 0 && document.") sbChkMileage.Append("getElementById(objTextBox3).value == objTextBox1.value + objTextBox2.value)}") sbChkMileage.Append("</SCRIPT>") RegisterStartupScript("PageStartupScriptChkMileage", sbChkMileage.ToString) sbChkMileage = Nothing </code> When I'm debugging and view the source code, I get the following in the View Source: <code> onChange="ChkMileage(document.getElementById('txtMileageBeginning'), document.getElementById('txtEnding'), document.getElementById('txtTotal'); <SCRIPT language='javascript'>function ChkMileage(objTextBox1, objTextBox2, objTextBox3) { if(objTextBox1.value.length > 0 && objTextBox2.value.length > 0 && document.getElementById(objTextBox3).value == objTextBox1.value + objTextBox2.value)}</SCRIPT> </code> While also debugging, there was no "running document"??? What am I doing wrong, because the javascript is not firing after I place values in the first two textboxes???
  16. I have two fields on my webform that I want calculated in my code-behind, but as I type in the controls, the events are not firing (as evidenced in debug mode). <code> Private Sub txtMileageBeginning_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMileageBeginning.TextChanged If (txtMileageBeginning.Text.Trim <> String.Empty) AndAlso (txtEnding.Text.TrimEnd <> String.Empty) Then txtTotal.Text = txtMileageBeginning.Text.Trim + txtEnding.Text.TrimEnd End If End Sub Private Sub txtEnding_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtEnding.TextChanged If (txtMileageBeginning.Text.Trim <> String.Empty) AndAlso (txtEnding.Text.TrimEnd <> String.Empty) Then txtTotal.Text = txtMileageBeginning.Text.Trim + txtEnding.Text.TrimEnd End If End Sub </code> How can I get these events to fire in order to dynamically calculate the total?
  17. I would like to place the currently selected date (retrieved from the database) on a calendar control which is embedded inside a datagrid. However, I can't find the ID of the control to do so. During the "Edit" command of the grid, I have the following code: <code> If e.CommandName = "Edit" Then Dim myDatagridItem As DataGridItem Dim lblStartDate As Label Dim lblEndDate As Label For Each myDatagridItem In dgPositions.Items lblStartDate = myDatagridItem.Controls.Item(4).FindControl("lblStartDate") lblEndDate = myDatagridItem.Controls.Item(5).FindControl("lblEndDate") Next End If </code> This code successfully retrieves the date. In edit mode, I have the textbox turning into a calendar control (When not in edit mode, it's simply a textbox dispolaying the date). When I go into edit mode, the selected date goes away. I want to take the date from the code above, and use it to set the calendar.selecteddate property so the user can see the present date selected in the calendar control. The following code only works during the OnupdateCommand and not during the "Edit" command of the grid: <code> Dim calStartDate As WebControls.Calendar = DirectCast(e.Item.FindControl("calStartDate"), WebControls.Calendar) Dim calEndDate As WebControls.Calendar = DirectCast(e.Item.FindControl("calEndDate"), WebControls.Calendar) </code> How can I properly set the "original" date to the calendar control during the edit process? Below, is what is in the HTML portion of my aspx page: <code> <asp:TemplateColumn HeaderText="StartDate"> <ItemTemplate> <asp:Label id=lblStartDate runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.StartDate", "{0:d}") %>'> </asp:Label> </ItemTemplate> <EditItemTemplate> <asp:Calendar id="calStartDate" Runat="server"> <TodayDayStyle Font-Size="XX-Small"></TodayDayStyle> <SelectorStyle Font-Size="XX-Small"></SelectorStyle> <DayStyle Font-Size="XX-Small"></DayStyle> <NextPrevStyle Font-Size="XX-Small"></NextPrevStyle> <DayHeaderStyle Font-Size="XX-Small"></DayHeaderStyle> <SelectedDayStyle Font-Size="XX-Small"></SelectedDayStyle> <TitleStyle Font-Size="XX-Small"></TitleStyle> <WeekendDayStyle Font-Size="XX-Small"></WeekendDayStyle> <OtherMonthDayStyle Font-Size="XX-Small"></OtherMonthDayStyle> </asp:Calendar> </EditItemTemplate> </asp:TemplateColumn> </code>
  18. I'd like to link to another part of my document within my aspx page. I have the following code in my HTML: <code> <A HREF="#PositionsHeld">Positions Held</A> <asp:label id="lblPosition" style="Z-INDEX: 107; LEFT: 16px; POSITION: absolute; TOP: 816px" runat="server" Font-Underline="True" Font-Bold="True" Font-Size="Larger">Positions Held</asp:label> <H2 id="PositionsHeld"></H2> </code> I would like the link to go directly right after the above label. I thought I would be achieving this by using the "<H2 id="PositionsHeld"></H2>" . When I click on the link, it brings me down some on the document, but nowhere near this label. What am I doing wrong?
  19. Is there some way I can add additional authorization in my web.config for a specific folder that checks IP address? I know I can place an additional web.config file in this specific folder, but what exact syntax can I place in the config file that would allow access only from specific IP addresses?
  20. You can't specify the sort property for the listbox when a datasource is present for that type of control. I solved it by sorting the datatable and eliminating the view.
  21. I had some of the statements reversed. I should have the datasource after the dataview.....
  22. I cannot get a dataview to sort at all based on the column name! Here is the following code that I'm using: <code> lstReturnContact.DataSource = dsRolodexXSD.CONTACTS.Select(dsRolodexXSD.CONTACTS.Columns(1).ToString & " <> ''") lstReturnContact.ValueMember = dsRolodexXSD.CONTACTS.Columns(0).ToString lstReturnContact.DisplayMember = dsRolodexXSD.CONTACTS.Columns(1).ToString dvFrAddr.Table = dsRolodexXSD.CONTACTS dvFrAddr.Sort = dsRolodexXSD.CONTACTS.Columns(1).ToString </code> The dsRolodexXSD.CONTACTS.Columns(1).ToString contains the value "CONTACTNAME". I even try putting the string in manually (just "CONTACTNAME"), but it still doesn't work. I'm not getting an error. The listbox comes up fine with the data, but it is not sorted at all. If the sort method couldn't find the columnname, I would get an error. Why is this not sorting???
  23. I'm having trouble trying to set a value to this property. When the calendar control is displayed alone on a webform (NOT inside a datagrid), the property is READ and WRITE. I am able to set a value to it. When the control is placed inside a datagrid column, I can't set the value of the SelectedDate property. It informs me that it's READONLY. Below, is the HTML on the ASPX page of what is happening: <code> <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="NCVACEMT.WebForm1"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:DataGrid id=DataGrid1 style="Z-INDEX: 101; LEFT: 504px; POSITION: absolute; TOP: 216px" runat="server" Height="416px" Width="712px" DataSource="<%# DsMeeting1 %>" DataKeyField="MeetingID" DataMember="Meeting" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn HeaderText="MeetingDate"> <ItemTemplate> <asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.MeetingDate") %>'> </asp:Label> <asp:Calendar id="Calendar1" runat="server"></asp:Calendar> </ItemTemplate> <EditItemTemplate> <asp:TextBox id=TextBox1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.MeetingDate") %>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> <asp:Calendar id="Calendar2" style="Z-INDEX: 102; LEFT: 104px; POSITION: absolute; TOP: 240px" runat="server"></asp:Calendar> </form> </body> </HTML> </code> Here is the code-behind: <code> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Calendar2.SelectedDate = "01/01/04" End Sub Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand Dim myDatagridItem As DataGridItem Dim c As Calendar For Each myDatagridItem In DataGrid1.Items c = myDatagridItem.FindControl("Calendar1") 'c = DirectCast(myDatagridItem.FindControl("Calendar1"), Calendar) c.SelectedDate = "01/01/04" Next 'and i also tried this: c = DirectCast(e.Item.FindControl("Calendar1"), Calendar) c.SelectedDate = "01/01/04" End Sub </code> In the page load event, the date gets set fine, but not in the above event. I even tried placing the above code inside the page load event as well (just setting calendar1.selecteddate to a date, but still didn't work). Can someone please inform me how I can set the SELECTEDDATE property. The reason being, is that once the data is loaded into a dataset, I want to set the value of the date on the calendar control to the SelectedDate.
×
×
  • Create New...