|
Hi,
In your select command of "sqldatasource" you should give that field name.
Sherin Iranimose
|
|
|
|
|
Thanks alot...i misses out the column name thats why i encounter the error..You are of a wonderful help, Sherin. May I ask you, how do i resize the textbox column in editing mode? I heard from my friends that it was fixed? How do I make it shorter in width? I got alot to learn from you...wonder if u have any email address or msn if you dun mind? :P anyway, Thank you so much for your help. I really appreciate it..
Regards,
Aaron Neo
|
|
|
|
|
hi AaronNeo,
Do you know one thing.. The controls inside "Edit item template field"
are same as other controls.So we can do whatever we like, on it.
So just resize it in design mode itself(from inside the "Edit item template field").
try...
vsherin@gmail.com
Sherin Iranimose
|
|
|
|
|
i am new to asp.net and have a code that works fine inline but doesnot work in vs 2005 code behind. someone please help
when the page loads all dropdownlist are empty however when you click search
button all results are displayed.on clicking paging number for next record it
again shows empty dropdown list.
here is the code:
code behind
Imports System
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
Imports System.Data
Imports System.Data.Odbc
Partial Class _Default
Inherits System.Web.UI.Page
Sub btnSearch_OnClick(ByVal sender As Object, ByVal e As EventArgs)
dgrdProducts.CurrentPageIndex = 0
Page_Load()
End Sub
Sub PageChange(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
dgrdProducts.CurrentPageIndex = e.NewPageIndex
Page_Load()
End Sub
Dim strBackGroundColor As String
Sub dropColors_SelectedIndexChanged(ByVal s As Object, ByVal e As EventArgs)
strBackGroundColor = dropColors.SelectedValue.ToString
End Sub
Dim strBackGroundColor2 As String
Sub dropColors_SelectedIndexChanged2(ByVal s As Object, ByVal e As EventArgs)
strBackGroundColor2 = dropColors2.SelectedValue.ToString
End Sub
Dim strBackGroundColor3 As String
Sub dropColors_SelectedIndexChanged3(ByVal s As Object, ByVal e As EventArgs)
strBackGroundColor3 = dropColors3.SelectedValue.ToString
End Sub
Sub Page_Load()
'1. Create a connection
Dim myConnection As New OdbcConnection("DSN=store")
Dim myConnection2 As New OdbcConnection("DSN=store")
Dim myConnection3 As New OdbcConnection("DSN=store")
'2. Create the command object, passing in the SQL string
Const strSQL As String = "select distinct category from products"
Const strSQL2 As String = "select distinct product from products"
Const strSQL3 As String = "select distinct price from products"
'Const strSQL as String = "SELECT distinct category, product, price FROM products"
'Const strSQL as String = "SELECT FAQID, LEFT(Description, 40) + '...' AS Description " & _
'"FROM tblFAQ ORDER BY Description"
Dim myCommand As New OdbcCommand(strSQL, myConnection)
Dim myCommand2 As New OdbcCommand(strSQL2, myConnection2)
Dim myCommand3 As New OdbcCommand(strSQL3, myConnection3)
'3. Create the DataReader
myConnection.Open()
myConnection2.Open()
myConnection3.Open()
Dim objDR As OdbcDataReader
Dim objDR2 As OdbcDataReader
Dim objDR3 As OdbcDataReader
objDR = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
objDR2 = myCommand2.ExecuteReader(CommandBehavior.CloseConnection)
objDR3 = myCommand3.ExecuteReader(CommandBehavior.CloseConnection)
'Databind the DataReader to the listbox Web control
If Not IsPostBack Then
dropColors.DataSource = objDR
dropColors.DataBind()
dropColors2.DataSource = objDR2
dropColors2.DataBind()
dropColors3.DataSource = objDR3
dropColors3.DataBind()
'Add a new listitem to the beginning of the listitemcollection
dropColors.Items.Insert(0, New ListItem("-- Choose a category --"))
dropColors2.Items.Insert(0, New ListItem("-- Choose a product --"))
dropColors3.Items.Insert(0, New ListItem("-- Choose price range --"))
End If
Dim dstProducts As DataSet
Dim dadProducts As OdbcDataAdapter
Dim strSQLQuery As String
Dim objConnection As OdbcConnection
Dim objCommand As OdbcCommand
Dim strBackGroundColor As String
Dim strBackGroundColor2 As String
Dim strBackGroundColor3 As String
strBackGroundColor = dropColors.SelectedValue.ToString
'strBackGroundColor = lstFAQs.SelectedValue.ToString
'Response.Write(strBackGroundColor)
'Response.End()
strBackGroundColor2 = dropColors2.SelectedValue.ToString
'strBackGroundColor2 = lstFAQs2.SelectedValue.ToString
'Response.Write("strBackGroundColor2")
strBackGroundColor3 = dropColors3.SelectedValue.ToString
'strBackGroundColor3 = lstFAQs3.SelectedValue.ToString
'Response.Write("strBackGroundColor3")
'Response.End()
If Len(Trim(strBackGroundColor)) >= 0 Then
' Set up our connection.
' Grab Products Table
dstProducts = New DataSet()
objConnection = New OdbcConnection("DSN=store")
' Set up our SQL query text.
strSQLQuery = "SELECT StoreID, category, product, status, description, price, stock, moreinformation, photo, priceactual, buy " _
& "FROM products " _
& "WHERE category LIKE '%" & Replace(strBackGroundColor, "'", "''") & "%' " _
& "AND product LIKE '%" & Replace(strBackGroundColor2, "'", "''") & "%' " _
& "AND price LIKE '%" & Replace(strBackGroundColor3, "'", "''") & "%' " _
& "ORDER BY status;"
'Response.Write(strSQLQuery)
'Response.End()
objCommand = New OdbcCommand(strSQLQuery, objConnection)
dadProducts = New OdbcDataAdapter(objCommand)
dadProducts.Fill(dstProducts, "products")
' Bind to DataGrid
dgrdProducts.DataSource = dstProducts
dgrdProducts.DataBind()
Else
End If
End Sub
End Class
here is aspx front end
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<table border=0 width=300 height=100 align=center>
<tr>
<td align=center>
<td >
<asp:DropDownList id="dropColors" runat="server" Rows="1"
OnSelectedIndexChanged="dropColors_SelectedIndexChanged"
AutoPostBack="false"
DataTextField="category" DataValueField="category" />
</td>
<td align=center>
<font color=black><b>Product :</b></font></td>
<td >
<asp:DropDownList id="dropColors2" runat="server" Rows="1"
OnSelectedIndexChanged="dropColors_SelectedIndexChanged2"
AutoPostBack="false"
DataTextField="Product" DataValueField="Product" />
</td>
<td align=center>
<font color=black><b>Price :</b></font></td>
<td >
<asp:DropDownList id="dropColors3" runat="server" Rows="1"
OnSelectedIndexChanged="dropColors_SelectedIndexChanged3"
AutoPostBack="false"
DataTextField="Price" DataValueField="Price" />
</td>
<td colspan=2 align=center>
<asp:Button id="btnSearch" runat="server"
Text = "Search"
OnClick = "btnSearch_OnClick"
/>
</td>
</tr>
</table>
<asp:DataGrid id="dgrdProducts" runat="server"
AutoGenerateColumns="False"
EnableViewState="False"
ShowHeader="true"
HeaderStyle-Font-Name="arial"
HeaderStyle-Font-Bold="true"
HeaderStyle-BackColor="lightblue"
ItemStyle-Font-Name="arial"
ItemStyle-Font-Size="10pt"
AlternatingItemStyle-BackColor="pink"
CellPadding="8"
cellspacing=0
AllowPaging = "True"
PageSize = "5"
OnPageIndexChanged = "PageChange">
<PagerStyle Mode="numericpages" />
<PagerStyle backcolor="lightblue" />
<PagerStyle font-bold="true" />
<Columns>
<asp:BoundColumn
HeaderText="Product"
DataField="product" />
<asp:BoundColumn
HeaderText="Description"
DataField="description" />
<asp:BoundColumn
HeaderText="Type"
DataField="status" />
<asp:BoundColumn
HeaderText="Price"
DataField="priceactual" />
<asp:TemplateColumn>
<itemTemplate>
<table>
<tr>
<td><a href='<%# String.Format( "details.aspx?id={0}", Container.DataItem( "StoreID" ) ) %>'>More Info</a></td><td><a href='<%# String.Format( "form_to_accessdb.aspx?id={0}", Container.DataItem( "StoreID" ) ) %>'>order now</a></td>
</tr>
<tr>
<img src= "<%# Container.DataItem( "photo" )%>" width=150 height=120></td>
</tr>
</table>
</itemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
i will really appreciate any help
-- modified at 12:27 Wednesday 9th May, 2007
|
|
|
|
|
to easily tracking the convertion...you just do a part of it...then post the problem here if you cannot overcome that...
<< >>
|
|
|
|
|
Your code is ripe for SQL injection attacks. Define 'doesn't work'. What does it do ? Can you pinpoint the bit that doesn't work ? No-one is going to read all of this...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I just want to know that I have already a web application. I want to use ajax in one of my web forms.
I installed AJAX in my machine. Now to use ajax in my web application should I create a new web site in VS 2005 and select ASP.Net AJAX - Enabled Site
and then copy my all the web forms and datasets from my existing web application to this new AJAX application to be able to use AJAX.
I am wondering if there is any other way to use AJAX in already existing web application.
Thanks in advance.
seema
|
|
|
|
|
Check this out - it's a video on how to do it
[Video]
|
|
|
|
|
Thanks a lot. It was very helpful for me.
seema
|
|
|
|
|
hello
thanks for the time
i have the next question
i have the next loop
For Each RowUsuarioAplicacion In oAplicacionBE.UsuarioAplicacion.Select(ExpresionFiltro)<br />
For Each RowAplicacion In oAplicacionBE.Aplicacion<br />
If Not RowUsuarioAplicacion.Item("AplicacionID") = RowAplicacion.Item("AplicacionID") Then<br />
oAplicacionBE.Aplicacion.RemoveAplicacionRow(RowAplicacion)<br />
End If<br />
Next<br />
Next
i whish delete all rows in RowAplicacion.Item("AplicacionID") that do not exist in RowUsuarioAplicacion.Item("AplicacionID")
but
when the code line oAplicacionBE.Aplicacion.RemoveAplicacionRow(RowAplicacion) is run and go the next
For Each RowAplicacion In oAplicacionBE.Aplicacion
i get the next message
Message "Collection was modified; enumeration operation might not execute." String
some one have any idea
I am trying to not create a temporary container
thanks for the time
ansorry for me english
|
|
|
|
|
You cannot modify a collection and enumerate it at the same time. In other words, if you are counting a stack of coins, and someone takes some coins from the counted stack, you have to start your count again.
You can do the following to solve your problem:
1. Search for all the AplicacionID's in one table that don't belong in the other table.
2. Extract the AplicacionID from each row found and place it in an AplicationID collection.
3. Enumerate through the AplicacionID collection, search for the AplicationID in the target table, and, if the AplicacionID is found, delete the row or rows.
|
|
|
|
|
Hello,
I converted a VS 2003 project to VS 2005. It works perfectly alright in VS 2003 but when I try running in VS 2005 I got strange thing going on. The code (my button click event ) runs twice? Has any one run into this kind of situation before please help. Am I missing some thing here? or do I need to set an option here?
Thanks,
-L
|
|
|
|
|
Is 'AutoEventWireup' set to 'true' on your web page?
If so, then any event handling methods starting with "Page_..." don't need to be wired up. In VB, they don't need to the 'Handles' clause or an AddHandler statement and in C# you don't need the "+=" event wireup.
Alternatively, you could just set 'AutoEventWireup' to 'false'.
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# to C++/CLI and VB to C++/CLI
Instant Python: converts C# to IronPython and VB to IronPython
|
|
|
|
|
I need to set the validation group name for all the controls on a page during the Page Load event.
Is there a way to do this using a Foreach type statement ?
|
|
|
|
|
Hi,
I have an application where on a lot of my ASP.NET pages i need to add text boxes which collect First Name, last Name, Age, Company Name etc and has a button which when clicked enters the above mentioned data into the database.It needs to be entered to the same database table all the time.No, I cannot use session info. I wanna know if it is possible to create a custom web control which does this? So I can add it to my tool box and drag and drop onto my pages as and when I need it. I havent seen instances where you can create a control which does db operation. I know you can use User controls(.ascx) but that way, it needs to be included in every project and every one can see the code and know whatz happening behind it. Help is appreciated. Samples are appreciated even more!!!
Regards
RH
|
|
|
|
|
Hey guys
I have a treeview with checkboxes being shown. I also have two buttons, one to check all the checkboxes and one to uncheck them all. I can do this in the code behind but was hoping someone can point me in the right direction for a javascript method so to avoid a postback. Thanks in advance.
A.
|
|
|
|
|
i am problem with loading images in Firefox using asp.net .images in the simple
image control are not getting displayed and listview with Images are displaying error but in IE6 every thing is working very fine;)
pls help
Thanks in advance
|
|
|
|
|
Do the image names have spaces in them, and are the slashes correct ("/" instead of "\")?
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
I have managed to fill a stream reader with this text:
""
My question is that how can i get the data inside td's and iterate until end of file and save them as table records.
Thanks
|
|
|
|
|
A sample solution using the string as an xml:
string data = String.Empty;
System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
xml.LoadXml("<html><table><tr><td>1</td><td>name</td><td>date</td><td>action</td></tr></table></html>");
System.Xml.XmlNodeList trs = xml.ChildNodes[0].ChildNodes[0].SelectNodes("tr");
foreach (System.Xml.XmlNode tr in trs)
{
System.Xml.XmlNodeList tds = tr.SelectNodes("td");
foreach (System.Xml.XmlNode td in tds)
{
data += td.InnerText + ",";
}
data.TrimEnd(new char[] { ',' });
data += "\r\n";
}
|
|
|
|
|
Wow, I can't beleive what I have been missing. I just recently found that if I drag my css file to my header section (or create a link to the css file), I can set all my style settings via cssClass property and the design view looks like how the page will be rendered.
Previously I was using skins and a .css file in the themes folder. However, when I put the style information in the Theme folder it was not applied in design view.
What gives? Is there no way to have a theme applied in design view, or am I just better off doing it the old school way with just a link to the .css file?
|
|
|
|
|
If you set the Theme in the Page directive or in the appropriate section of web.config, it should display just fine. However if you set the Theme from code (Page.Theme = "Theme1"), then the design view will be not available to show it.
Sidenote: sadly the VS2005 designer is not capable of rendering complex layouts achieved with divs and CSS, so it is better not to rely on it. Use "View page in browser" option instead.
|
|
|
|
|
Nope. I set the theme in the page directive and did not apply any theme elements.
|
|
|
|
|
I now realize when I wrote Theme it should be interpreted as StyleSheetTheme. I have the bad habit of mixing those two up, since I always use the StyleSheetTheme attribute for Themes. 
|
|
|
|
|
Hi friends
I am workig in asp.net with c#
I have one textbox and one list box.
when Enter City in textbox and lost focos from there,I want to fill Airport code in List box from the database.
Plz anyone can give me solution or any link.
Thanks in advance
pathan
GOD HELP THOSE WHO HELP THEMSELVES
|
|
|
|