Saturday, March 31, 2012
Subroutine /helper function error
would be displayed inside a datalist control's <itemtemplate> )
<script language="VB" runat="server">
Public Sub checkforimg(ByVal Imagesubprod1 As String)
If Imagesubprod1 <> "" then
response.write(Imagesubprod1)
Else
response.write("nbsp;")
End If
End Sub
</script>
... but I get an "Overload resolution failed because no accessible
'ToString' can be called with these arguments:" error when it comes
time to check for the image as follows.
<%# checkforimg(DataBinder.Eval(Container.DataItem,
"Imagesubprod1"))%>
When I form the header for the sub as follows:
Public Sub checkforimg(ByVal Imagesubprod1 As String) As string
..i get an "Expected end of statement " error on this lineOn 10 Jun 2004 11:55:42 -0700, Chumley the Walrus <springb2k@.yahoo.com>
wrote:
> I'm using a subroutine/helper function display an image (the image
> would be displayed inside a datalist control's <itemtemplate> )
> <script language="VB" runat="server">
> Public Sub checkforimg(ByVal Imagesubprod1 As String)
> If Imagesubprod1 <> "" then
> response.write(Imagesubprod1)
> Else
> response.write("nbsp;")
> End If
> End Sub
> </script>
> ... but I get an "Overload resolution failed because no accessible
> 'ToString' can be called with these arguments:" error when it comes
> time to check for the image as follows.
> <%# checkforimg(DataBinder.Eval(Container.DataItem,
> "Imagesubprod1"))%>
looks like it's having trouble converting the value you're passing in thru
databinding to a String. If you have Option Strict on, you might try
either casting the value in the databinding statement to a string before
passing it in, or change the parameter in your method above to an Object
and then cast it inside the function itself.
Otherwise verify the value in your datasource is truly capable of being a
string.
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
IE does not support inline images, so you code should be writing something
like: <img src=url> not the binary image.
-- bruce (sqlwork.com)
"Chumley the Walrus" <springb2k@.yahoo.com> wrote in message
news:1ef65641.0406101055.8852102@.posting.google.com...
> I'm using a subroutine/helper function display an image (the image
> would be displayed inside a datalist control's <itemtemplate> )
> <script language="VB" runat="server">
> Public Sub checkforimg(ByVal Imagesubprod1 As String)
> If Imagesubprod1 <> "" then
> response.write(Imagesubprod1)
> Else
> response.write("nbsp;")
> End If
> End Sub
> </script>
> ... but I get an "Overload resolution failed because no accessible
> 'ToString' can be called with these arguments:" error when it comes
> time to check for the image as follows.
> <%# checkforimg(DataBinder.Eval(Container.DataItem,
> "Imagesubprod1"))%>
> When I form the header for the sub as follows:
> Public Sub checkforimg(ByVal Imagesubprod1 As String) As string
> ..i get an "Expected end of statement " error on this line
Wednesday, March 28, 2012
substitute data from database into web form
Hello.
Newbie here, I have a field in a database called status with the values "I" or "A". I need to display "Inactive" or "Active" in a gridview or formview web page. How do I substitute these values.
Thanks in advance.
Is this data being displayed in a datalist / datagrid? You can either create a temp table in your sql or modify your code. If you post your code I can show you how, otherwise you can do something like this in your sql:
create table #temp(
activeInactiveField1 char(5)
, activeInactiveField2 char(10)
-- , your other fields here
)
Insert into #Temp(
-- all fields from your existing sql
from all your existing tables
update #temp
set activeInactiveField2 = 'Active'
where activeInactiveField1 = 'A'
update #temp
setActiveInactiveField2 = 'Inactive'
where activeInactiveField1 = 'I'
select * from #Temp
drop table #Temp
Then you can databind the field in your webform to activeInactiveField2
Hello, Thank you for the quick response. Below is my code. As stated I am a newbie and the filed I am working with is status. Thanks a lot.
<%@.PageLanguage="VB"AutoEventWireup="false"CodeFile="Default2.aspx.vb"Inherits="Default2" %>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title></head>
<body>
<formid="form1"runat="server">
<div>
<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"DataSourceID="SqlDataSource1"
Style="z-index: 100; left: 0px; position: absolute; top: 0px">
<Columns>
<asp:BoundFieldDataField="Citation"HeaderText="Citation"SortExpression="Citation"/>
<asp:BoundFieldDataField="Type"HeaderText="Type"SortExpression="Type"/>
<asp:BoundFieldDataField="Status"HeaderText="Status"SortExpression="Status"/>
<asp:BoundFieldDataField="Last Name"HeaderText="Last Name"SortExpression="Last Name"/>
<asp:BoundFieldDataField="First Name"HeaderText="First Name"SortExpression="First Name"/>
<asp:BoundFieldDataField="Middle"HeaderText="Middle"SortExpression="Middle"/>
<asp:BoundFieldDataField="DOB"HeaderText="DOB"SortExpression="DOB"/>
<asp:BoundFieldDataField="Violation Date"HeaderText="Violation Date"SortExpression="Violation Date"/>
<asp:BoundFieldDataField="Charge"HeaderText="Charge"SortExpression="Charge"/>
<asp:BoundFieldDataField="Description"HeaderText="Description"SortExpression="Description"/>
<asp:BoundFieldDataField="Disposition"HeaderText="Disposition"SortExpression="Disposition"/>
<asp:BoundFieldDataField="Cost"HeaderText="Cost"SortExpression="Cost"/>
<asp:BoundFieldDataField="Paid"HeaderText="Paid"SortExpression="Paid"/>
<asp:BoundFieldDataField="Balance"HeaderText="Balance"SortExpression="Balance"/>
</Columns>
</asp:GridView>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:MUNI_COURTConnectionString4 %>"
ProviderName="<%$ ConnectionStrings:MUNI_COURTConnectionString4.ProviderName %>"
SelectCommand="SELECT * FROM [MUNI_COURT_REC]"></asp:SqlDataSource>
</div>
</form></body>
</html>
You can handle this in RowDataBound event of the gridview. To add this event to your gridview, when in design view of Visual Studio, click on gridview once to get the properties window. From that, go to the events window (identified by a small "lightning" icon) and look for RowDataBound event. Double click on this event and an event hadler will created in your code file. Just copy and paste this code there.
protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e) {if (e.Row.RowType == DataControlRowType.DataRow) {if(e.Row.Cells[7].Text =="A") { e.Row.Cells[7].Text ="Active"; }else { e.Row.Cells[7].Text ="Inactive"; } } }Or you can change your select statement - something like select case status when 'i' then 'inactive' else 'active' end as status from blah blah blah...
By the way, it's never good practice to do a select *.
Hi, try this inline IIF statement to evaulate the status field and display conditional text. You will have to first convert your GridView to a template so you have control over the HTML controls.
<asp:LabelID="LabelStatus"runat="server"Text='<%# IIF(CONVERT.ToString(Eval("Status"))="A","Active", "Inactive") %>'></asp:Label>
Thanks I got that suggestion to work in a gridview and formview.
What if I had another field called type that I had to change
"H" to "Harbor"
"C" to "Civil"
"T" to "Traffic"
"L" to "Local"
You can use the same solutions that are marked as answer to extend the functionality. Like in mine, you can access the columns by their index (0 based). So whatever the index of your "Type" column, access it in RowDataBound event, check the text of the cell, and change it accordigly.
Sorry bullpit,
when I run your suggestion I get the following error message
Compiler Error Message:BC30205: End of statement expected.
I believe your suggestion would work best.
I forgot to uncheck the answer message button
Paste your code here. Please use the InsertCode option in the text editor.
Partial Class Default2 Inherits System.Web.UI.Page Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBoundprotected void gridView1_RowDataBound(object sender, GridViewRowEventArgs e) {if (e.Row.RowType == DataControlRowType.DataRow) {if(e.Row.Cells[7].Text =="A") { e.Row.Cells[7].Text ="Active"; } Else { e.Row.Cells[7].Text ="Inactive"; } } } End SubEnd Class
Thanks
learn_asp_fast:
Partial Class Default2 Inherits System.Web.UI.Page Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBoundprotected void gridView1_RowDataBound(object sender, GridViewRowEventArgs e) {if (e.Row.RowType == DataControlRowType.DataRow) {if(e.Row.Cells[7].Text =="A") { e.Row.Cells[7].Text ="Active"; } Else { e.Row.Cells[7].Text ="Inactive"; } } } End SubEnd Class
The piece of code I posted was an event handler for RowDataBound event. An event handler is a method (function) by itself. What you did was that you attached an event handler the way I mentioned (by double clicking the RowDataBound event in designer) but also copied and pasted the event handler that I posted into the event handler that the designer generated. So now you have a function defined in another function, which is not right. Morover, you are using VB and the code I pasted was C#. Change the above code to this:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBoundIf e.Row.RowType = DataControlRowType.DataRowThen If e.Row.Cells(7).Text ="A"Then e.Row.Cells(7).Text ="Active"Else e.Row.Cells(7).Text ="Inactive"End If End If End Sub
Bullpit,
Thank you very much for your time. I did realize I pasted the code into another function, but neith er way worked for me. I should be able to get this sample to work in other ways for me.
This a very helpful board.
Also, change the column index (7 in the code I posted) to the column index where you want to change the text. That might be the problem. For example, in your gridview, the "STATUS" colum index maybe 4 instead of 7.
Bullpit,
If you do not mind hopw do I get that to work in a Formview?
Thanks in advance
Monday, March 26, 2012
Suggestion for next release of 2.0 - ValidationSummary Control
I have a feature request for 2.x or 3.x. How about we have the option
to let the ValidationSummary display messages from all validators on
the page? For instance, maybe we can have an additional property
"DisplayAllValidators."
Or maybe you can just modify the ValidationGroup property on the
summary control to work like this:
1. Undefined - Summarize all undefined Validators ignoring those with a
defined group
2. Defined - Summarize only the specified group's validators
3. All - Summarize every validator on the page (including those in user
controls)
That would be nice!
Forcing us to place multiple summary controls for each group on a page
is pretty lame. Allowing us the ability is nice...you could also just allow us to enter comma delimited Groups. I still
like my first suggestion better but at least that would solve my
problem.
re:
Quote:
Originally Posted by
I have a feature request for 2.x or 3.x.
Please submit that request at the Visual Studio
and .NET Framework Feedback page :
http://connect.microsoft.com/feedba...aspx?SiteID=210
Click on the "Submit Feedback" link and make sure you have a Microsoft Passport
handy so you can login, which is required in order to be able to submit requests and bugs.
If you don't have a Passport, get a free one here :
https://accountservices.passport.ne...?vv=410&lc=1033
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"r2thej151" <csharpdesign@.gmail.comwrote in message
news:1155851585.512982.134980@.i3g2000cwc.googlegro ups.com...
Quote:
Originally Posted by
Hi Guys,
>
I have a feature request for 2.x or 3.x. How about we have the option
to let the ValidationSummary display messages from all validators on
the page? For instance, maybe we can have an additional property
"DisplayAllValidators."
>
Or maybe you can just modify the ValidationGroup property on the
summary control to work like this:
1. Undefined - Summarize all undefined Validators ignoring those with a
defined group
2. Defined - Summarize only the specified group's validators
3. All - Summarize every validator on the page (including those in user
controls)
>
That would be nice!
>
Forcing us to place multiple summary controls for each group on a page
is pretty lame. Allowing us the ability is nice...
>
thanks for the link. it is already filed and open.
Suggestion/Reference/Idea on creating bulleting board by asp.net
You may find many examples in the following links:
http://asp.net/ControlGallery/default.aspx?Category=34&tabindex=2
http://www.hotscripts.com/ASP.NET/Scripts_and_Controls/Discussion_Boards/index.html
Hope it helps.
Saturday, March 24, 2012
Sum result in Label field
I summed a column of numbers and would like to put them in a Label field to display the result. I understand the conversion for number to string, I don't understand how to that value, that has been summed, to do it.
thanks
grady
int x = 7;
int y = 7;
int z = x + y;
LabelID.Text = z.ToString();
Is that what you're looking for?
HTH,
Ryan
Actually I have summed a column called TFsum and I was trying to display that and it say it was undeclared.
Here is the SQL:
SELECT SUM(filesfailed) AS TFsum
FROM accmonreport
WHERE oa='ddlOA'
HAVING SUM(filesfailed)=0
ddlOA is a dropdown list in the first view on the page. I'm just to get the variable TFsum to do some calculations.
thanks
grady
Could you post the relevent code?
Ryan
All I'm trying now is get the TFsum value into the lblcompliant label.
thanks
grady
Imports System.Data
Imports System.Data.OleDB
Imports System.Data.OleDb.OleDbDataReader
Partial Class reports_508report
Inherits System.Web.UI.Page
Protected Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If (Page.IsValid) Then
Dim ddlOA As String = ddloalist.SelectedValue
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"c:\accmon\database\accmon.mdb" & ";"
Dim MySQL As String = "SELECT SUM(filesfailed)AS TFsum FROM accmonreport WHERE oa='ddlOA' HAVING filesfailed=0"
Dim MyConn As New OleDbConnection(strConn)
Dim cmd As New OleDbCommand(MySQL, MyConn)
MyConn.Open()
cmd.ExecuteReader()
MyConn.Close()
lblCompliant.Text = " "
OAReport.SetActiveView(Result)
End If
End Sub
End Class
You need to make a couple of changes.
If (Page.IsValid) Then
Dim ddlOA As String = ddloalist.SelectedValue
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"c:\accmon\database\accmon.mdb" & ";"
Dim MySQL As String = "SELECT SUM(filesfailed)AS TFsum FROM accmonreport WHERE oa='" & ddlOA & "' HAVING filesfailed=0"
Dim reader As OleDbDataReader
Dim MyConn As New OleDbConnection(strConn)
Dim cmd As New OleDbCommand(MySQL, MyConn)
MyConn.Open()
reader =cmd.ExecuteReader()
While reader.Read()
lblCompliant.Text = reader("TFsum")
End While
reader.Close()
MyConn.Close()
OAReport.SetActiveView(Result)
End If
HTH,
Ryan
Thanks, I really appreciate your time and knowledge. If you don't mind, I have one more question. In Coldfusion there is a function that gives me a recordcount after every query. How do you implement something like that in .Net?
thanks
grady
Thursday, March 22, 2012
Support Trouble ticket type deal
I'm trying to make a support ticket system, I would like to know
How would you display how many replies an issue hasthe date of the last replyThanks
What is your DB architecture like?
I would have 2 tables:
(1) Tickets which contains all ticket information such as title, issue, member who submitted the ticket, createDate, and TicketID.
(2) TicketReplies which contains all replies for a ticket, a createDate, and a foreign key TicketID.
You can set createDate default binding = getDate() which will return the current dateTime.
If you need to know how many replies there are for a ticket you can run:
SELECT COUNT(*)
FROM TicketReplies tr
JOIN Tickets t
ON tr.TicketID = t.TicketID
WHERE t.TicketID = (whatever the ticket is that you are interested in)
If you need to know the date of the last reply you can run:
SELECT *
FROM TicketReplies tr
JOIN Tickets t
ON tr.TicketID = t.TicketID
WHERE t.TicketID = (whatever the ticket is that you are interested in)
ORDER BY CreateDate DESC
Supported by the .NET Compact Framework.
I want to know what is the compact framework.
Since i find many properties display with these keywords - Supported by the .net compact framework
http://msdn2.microsoft.com/fr-fr/netframework/aa497273.aspx
Suppress Masterpage
I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so you
can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?
JonasSure, just don't specify a master page for the popup window.
In the page header, don't add a MasterPageFile attribute.
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Jonas Pedersen" <qwert@.qwerty.com> wrote in message
news:O$vof7RJIHA.484@.TK2MSFTNGP06.phx.gbl...
> hi,
> I am looking into reusing code to limit number of pages.
> When ever I display a user's name on the site, It is with a hyperlink so
> you can view the user profile in a popup window.
> Is there a way to suppress the masterpage when a page is shown in my popup
> windows?
> Jonas
>
Suppress Masterpage
I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so you
can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?
JonasSure, just don't specify a master page for the popup window.
In the page header, don't add a MasterPageFile attribute.
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Jonas Pedersen" <qwert@.qwerty.comwrote in message
news:O$vof7RJIHA.484@.TK2MSFTNGP06.phx.gbl...
Quote:
Originally Posted by
hi,
>
I am looking into reusing code to limit number of pages.
When ever I display a user's name on the site, It is with a hyperlink so
you can view the user profile in a popup window.
Is there a way to suppress the masterpage when a page is shown in my popup
windows?
>
Jonas
>
Supressing Menu and Toolbars on Webpage
I'd like for my ASP.NET application to look like an application and not have
to display the menu and toolbars in the browser window.
In order to do this now I use a response.write and imbed javascript to do
window.open and include parameters to suppress these items. This causes
problems for users that have a popup stopper installed as the resulting
window is a popup and is usually suppressed.
Please let me know if you have any tips on a workaround for this issue.
I'd also like to find a way to automatically maximize the browser window
since the app looks better in full screen mode.
Any help you all can provide is greatly appreciated.
Thanks, Herbfor the maximize try
fullscreen=yes
as for a workaround for the pop-up blocker... God I hope not. That would
defeat the purpose. Tell you clients to "not block" your site.
Personally...any site that tries to even resize my window is immediately
put on my "do not visit" list. I think you may want to revisit your
approach... Web apps should never adjust or take over any settings on a
client's machine really, especially not if it's a public site.
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Herb Stull" <stullhe@.nauticom.net> wrote in message
news:403cd2e1$1_2@.news.nauticom.net...
> Hello All,
> I'd like for my ASP.NET application to look like an application and not
have
> to display the menu and toolbars in the browser window.
> In order to do this now I use a response.write and imbed javascript to do
> window.open and include parameters to suppress these items. This causes
> problems for users that have a popup stopper installed as the resulting
> window is a popup and is usually suppressed.
> Please let me know if you have any tips on a workaround for this issue.
> I'd also like to find a way to automatically maximize the browser window
> since the app looks better in full screen mode.
> Any help you all can provide is greatly appreciated.
> Thanks, Herb
Curt:
I have an application for an intranet that I'm writing and I would like to
start the users in full screen mode when they begin the application.
Presently I tell them to press F11 to go to full screen - is there a way to
call the 'fullscreen=yes' from within VB.NET - or is there a way that I can
do it with a javascript on the default.aspx page?
Thanks,
Fred
"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:OC1IC17%23DHA.1956@.TK2MSFTNGP10.phx.gbl...
> for the maximize try
> fullscreen=yes
> as for a workaround for the pop-up blocker... God I hope not. That would
> defeat the purpose. Tell you clients to "not block" your site.
> Personally...any site that tries to even resize my window is immediately
> put on my "do not visit" list. I think you may want to revisit your
> approach... Web apps should never adjust or take over any settings on a
> client's machine really, especially not if it's a public site.
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> www.Darkfalz.com
>
> "Herb Stull" <stullhe@.nauticom.net> wrote in message
> news:403cd2e1$1_2@.news.nauticom.net...
> > Hello All,
> > I'd like for my ASP.NET application to look like an application and not
> have
> > to display the menu and toolbars in the browser window.
> > In order to do this now I use a response.write and imbed javascript to
do
> > window.open and include parameters to suppress these items. This causes
> > problems for users that have a popup stopper installed as the resulting
> > window is a popup and is usually suppressed.
> > Please let me know if you have any tips on a workaround for this issue.
> > I'd also like to find a way to automatically maximize the browser window
> > since the app looks better in full screen mode.
> > Any help you all can provide is greatly appreciated.
> > Thanks, Herb
Just so you're aware-- going fullscreen without the user's permission is
going to get harder in Windows XP SP2.
If you want the user to see your application in fullscreen mode, why not
give them a custom .HTA file to run which pulls in your webpage in an
IFRAME?
--
Thanks,
Eric Lawrence
Program Manager
Assistance and Worldwide Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Fred Nelson" <fred@.smartybird.com> wrote in message
news:Ocwm1J8#DHA.2480@.TK2MSFTNGP12.phx.gbl...
> Curt:
> I have an application for an intranet that I'm writing and I would like to
> start the users in full screen mode when they begin the application.
> Presently I tell them to press F11 to go to full screen - is there a way
to
> call the 'fullscreen=yes' from within VB.NET - or is there a way that I
can
> do it with a javascript on the default.aspx page?
> Thanks,
> Fred
>
> "Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
> news:OC1IC17%23DHA.1956@.TK2MSFTNGP10.phx.gbl...
> > for the maximize try
> > fullscreen=yes
> > as for a workaround for the pop-up blocker... God I hope not. That
would
> > defeat the purpose. Tell you clients to "not block" your site.
> > Personally...any site that tries to even resize my window is
immediately
> > put on my "do not visit" list. I think you may want to revisit your
> > approach... Web apps should never adjust or take over any settings on a
> > client's machine really, especially not if it's a public site.
> > --
> > Curt Christianson
> > Owner/Lead Developer, DF-Software
> > www.Darkfalz.com
> > "Herb Stull" <stullhe@.nauticom.net> wrote in message
> > news:403cd2e1$1_2@.news.nauticom.net...
> > > Hello All,
> > > > I'd like for my ASP.NET application to look like an application and
not
> > have
> > > to display the menu and toolbars in the browser window.
> > > > In order to do this now I use a response.write and imbed javascript to
> do
> > > window.open and include parameters to suppress these items. This
causes
> > > problems for users that have a popup stopper installed as the
resulting
> > > window is a popup and is usually suppressed.
> > > > Please let me know if you have any tips on a workaround for this
issue.
> > > > I'd also like to find a way to automatically maximize the browser
window
> > > since the app looks better in full screen mode.
> > > > Any help you all can provide is greatly appreciated.
> > > > Thanks, Herb
> >