|
Thanks for your Replay, But Where is the Serverside code to bind the DropDownList
Mkanchha
|
|
|
|
|
Hi,
I have a usercontrol.It is having a dropdownlist dp1. I want to know how to bind/associate events to that usercontrol. For e.g. if i place that usercontrol on a web page then on the selected index change of the dropdownlist(dp1) of the usercontrol, i want an event to get fired.
Does anyone have a clue on how to do it.
Note: The dropdownlist(dp1) is generated using html and is not used directly from the toolbox.
Thanks,
Riz
|
|
|
|
|
Rajiya wrote: The dropdownlist(dp1) is generated using html and is not used directly from the toolbox.
Are you talking about custom control ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
ya...it is a custom control.
Below is the code used for creating the control:
<LINK href="toolTip.css" type="text/css" rel="stylesheet">
<script language="javascript" src="toolTip.js"></script>
<OBJECT id="combo" style="WIDTH: 156px; HEIGHT: 24px" height="24" width="156" classid="clsid:8BD21D30-EC42-11CE-9E0D-00AA006002F3"
name="combo" VIEWASTEXT>
<PARAM NAME="VariousPropertyBits" VALUE="746604571">
<PARAM NAME="BackColor" VALUE="16777215">
<PARAM NAME="ForeColor" VALUE="2147483656">
<PARAM NAME="MaxLength" VALUE="0">
<PARAM NAME="BorderStyle" VALUE="2">
<PARAM NAME="ScrollBars" VALUE="0">
<PARAM NAME="DisplayStyle" VALUE="7">
<PARAM NAME="MousePointer" VALUE="1">
<PARAM NAME="Size" VALUE="4128;635">
<PARAM NAME="PasswordChar" VALUE="0">
<PARAM NAME="ListWidth" VALUE="4000">
<PARAM NAME="BoundColumn" VALUE="1">
<PARAM NAME="TextColumn" VALUE="65535">
<PARAM NAME="ColumnCount" VALUE="1">
<PARAM NAME="ListRows" VALUE="8">
<PARAM NAME="cColumnInfo" VALUE="0">
<PARAM NAME="MatchEntry" VALUE="1">
<PARAM NAME="ListStyle" VALUE="1">
<PARAM NAME="ShowDropButtonWhen" VALUE="2">
<PARAM NAME="ShowListWhen" VALUE="1">
<PARAM NAME="DropButtonStyle" VALUE="1">
<PARAM NAME="MultiSelect" VALUE="0">
<PARAM NAME="Value" VALUE="">
<PARAM NAME="Caption" VALUE="">
<PARAM NAME="PicturePosition" VALUE="458753">
<PARAM NAME="BorderColor" VALUE="0">
<PARAM NAME="SpecialEffect" VALUE="3">
<PARAM NAME="Accelerator" VALUE="2">
<PARAM NAME="GroupName" VALUE="">
<PARAM NAME="FontName" VALUE="Arial">
<PARAM NAME="FontEffects" VALUE="1073741824">
<PARAM NAME="FontHeight" VALUE="170">
<PARAM NAME="FontOffset" VALUE="0">
<PARAM NAME="FontCharSet" VALUE="0">
<PARAM NAME="FontPitchAndFamily" VALUE="2">
<PARAM NAME="ParagraphAlign" VALUE="1">
<PARAM NAME="FontWeight" VALUE="200">
</OBJECT> <!-- code for the combo box-->
<P></P>
</A>
I want to know how to add events or event handlers to it.
regards,
Riz
|
|
|
|
|
Rajiya wrote: <object id="combo" style="WIDTH: 156px; HEIGHT: 24px" height="24" width="156" classid="clsid:8BD21D30-EC42-11CE-9E0D-00AA006002F3"
="" name="combo" viewastext="">
I think it is not ASP control
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Assuming that you have have developed a proper custom control
now you can add events to it take a look at this example
http://msdn2.microsoft.com/en-us/library/aa720416(VS.71).aspx[^]
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi,
I went through the link that u had suggested but did not get the information that i needed. Do u have any other link which cud give me the necessary details.I wanted to know how cud i get the selected index change event of that particular custom dropdownlist. Is is not an asp.net control.
Regards,
Riz
|
|
|
|
|
Hi friends,
I got problem when i redirects from one http page to other https page then , my page from which i am redirecting is reloads first time.
can any one tell me why this is happening ?
i have simple anchor tag like <a href="https://....>Registration</a>
when i click on that my page which contains that anchor tag is reloaded.
is it necessary to set "requireSSL="True"" in web.config for this type of redirection in same application.
Thanks.
-- modified at 5:09 Wednesday 9th May, 2007
Chirag Patel
|
|
|
|
|
Your anchor tag is not visible. Modify your message and use ignore HTML tags option.
|
|
|
|
|
I need to limit the number of characters entered by the user in a Textbox to 1000.setting MaxLength property doesnt work.
ravi
|
|
|
|
|
Hi friend,
Its working properly here.
is it not working only greater values like 1000.
Sherin Iranimose
|
|
|
|
|
Hi Everyone,
I would like to know how am I able to access the templateField I created in my GridView, which I set it to invisible initially, to make it visible when user click on the EDIT button and subsequently update into the database for the selected value.
|
|
|
|
|
Try with Javascript for making the combo box as visible when the user clicks edit button in the Grid view.
Regards,
Satips.
|
|
|
|
|
Hi,
When You create template field for edit, make it as "edit item template".
No need to make invisible.
An "edit item template" will automatically display when you press edit link.
Sherin Iranimose
|
|
|
|
|
Thank you so much for your help. I am quite new to asp.net so i may be asking some silly questions. Can I ask you another question? When I enter editing mode, how do i set the value of the combobox to the record in my database. If the user changes it, how do get the value of the combobox and update it back to the database ?
|
|
|
|
|
hi,
For make editing using gridview you should do following things.
1. Enable AutogenerateEditButton property of 'gridview' to true
2. Add Dropdownlist in to 'Item template' of 'gridview'
///
<asp:DropDownList ID="DropDownList1" runat="server" Width="126px"
DataSourceID="SqlDataSource1" DataTextField="Field2"
DataValueField="Field1" SelectedValue='<%# Bind("Field1") %>'>
</asp:DropDownList>
///
3. Add Dropdownlist in to 'Edit item template' of 'gridview'
/////
<asp:DropDownList ID="DropDownList2" runat="server" Width="126px"
DataSourceID="SqlDataSource1" DataTextField="Field2"
DataValueField="Field1" SelectedValue='<%# Bind("Field1") %>'>
</asp:DropDownList>
/////
4. Add an sqldatasource to your form
////
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="server=yourserver;Integrated Security=yes;Database=YourDatabase"
SelectCommand="SELECT [field1], [field2] FROM [YourTable]"></asp:SqlDataSource >
////
Now it will show the data in your table.
4. To update the data...
You should specify an "UpdateCommand" to the sqldatasource of your "gridview".
ex: UpdateCommand="UPDATE [YourTable] SET [field1]=@field1 WHERE [field2]=@field2"
Try...............
-- modified at 6:03 Wednesday 9th May, 2007
Sherin Iranimose
|
|
|
|
|
HI,
Thank you so much for your wonderful reply. I still can't get it to work..The user changes the category from the category Combobox and I need it to update the selected category to the database. The rest of the fields in the editing mode are textboxes, so there are no problem with updating them. The bind command doesn't work as it says categoryName can't be found? Without the bind and inputing @categoryname doesn't reflect the selected comboxItem...I tried controlParameter under the updateParameter but it doesn't work as well...I am so lost....
|
|
|
|
|
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]
|
|
|
|