|
There is no direct way to do it. You have to use some third party libraries available in the net freely.
Pradipta Basu
|
|
|
|
|
Thank you. Do you know of any specific sites where I could find these libraries? Or, can you suggest a good phrase to put in my search to find that information?
|
|
|
|
|
|
|
Thank you but when I clicked the link I got a page not found.
|
|
|
|
|
I have a web application data entry form and on the form I need to populate four drop down lists from four different database tables.
I placed ONE SqlDataSource control on the web page and in the Page_Load subroutine I placed the following code.
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Load
'Retrieve the datasource connection string from the Web.Config file
DtaSource.ConnectionString = MRMFunctions.WebConfigConnString
'Retrieve Employee titles from the database
Dim strTitleSQL = "SELECT * FROM tblTitles WHERE [Deleted] = 0;"
DtaSource.SelectCommand = strTitleSQL
cboTitle.DataSourceID = DtaSource.ID.ToString
cboTitle.DataTextField = "Title"
cboTitle.DataValueField = "TitleID"
DtaSource.Dispose()
'Retrieve the department names from the database
Dim strDeptSQL = "SELECT * FROM tblDepartments WHERE [Deleted] = 0;"
DtaSource.SelectCommand = strDeptSQL
cboDept.DataSourceID = DtaSource.ID.ToString
cboDept.DataTextField = "Department"
cboDept.DataValueField = "DeptID"
DtaSource.Dispose()
'Retrieve the address types from the database
Dim strAddrTypeSQL = "SELECT * FROM tblAddressTypes WHERE [Deleted] = 0;"
DtaSource.SelectCommand = strAddrTypeSQL
cboAddrType.DataSourceID = DtaSource.ID.ToString
cboAddrType.DataTextField = "AddressType"
cboAddrType.DataValueField = "AddressTypeID"
DtaSource.Dispose()
'Retrieve state names from the database
Dim strStateSQL = "SELECT * FROM tblStates;"
DtaSource.SelectCommand = strStateSQL
cboAddrType.DataSourceID = DtaSource.ID.ToString
cboAddrType.DataTextField = "StateAbbr"
cboAddrType.DataValueField = "StateID"
DtaSource.Dispose()
End Sub
When I run the form I get the following error:
Server Error in ‘/DataEntry’ Application
DataBinding: ‘System.Data.DataRowView’ does not contain a property with the name ‘Title’. I assume this error is being caused by the next set of databinding instructions(Retrieve the department names), because the resources are not being released after the first combo box is populated.
The funny thing is: When I place another SqlDataSource control on the page and modify the second set of data retrival instructions to access this control. The second combo box is populated correctly(no surprise here).
There has got to be a way I can get away with using only one SqlDataSource control, but my extreme lack of ASP.NET experience is hindering my efforts. Does anyone know a way of accomplishing this task?
Thank you,
Quecumber256
|
|
|
|
|
#1: Why are you disposing DtaSource all over the place?
#2: Create a connection, command and do it that way. Also remember DataBind.
|
|
|
|
|
ednrgc wrote: #1: Why are you disposing DtaSource all over the place?
Intuitively, I thought after the first combobox was populated I would release its resources and then populate the next combobox by resetting the poperties on the SQLDataSource again. My extreme inexperiance in ASP.NET is showing.
ednrgc wrote: #2: Create a connection, command and do it that way. Also remember DataBind.
I have a function that retrieves the connection string for the SQL database I'm using. I remember DataSets from making a Windows application. I'm making a Web application, and I don't think we can use a DataSet. Do you have an example of using one SqlDataSource and using it to bind data to multiple combo boxes?
Silly question: Is databinding limited to one datasource being bound to one control? Example: SqlDataSource1 data bound to ComboBox1, SqlDataSource2 data bound to ComboBox2 and so on.
Thank you,
Quecumber256
|
|
|
|
|
use a dataset(i mean one ds) and populate teh dataset with the datatables you need for your dropdown boxes. You need to write a function to return teh dataset before you bind your dropdown controls with teh datatable. the binding will look like this after teh function call
ddControl1.datasource=ods("table1")
ddControl1.databind
ddControl2.datasource=ods("table2")
ddControl2.databind
ddControl3.datasource=ods("table3")
ddControl3.databind
t.aransiola
|
|
|
|
|
Hi,
Im using the membership provider in asp.net2.0 - excellent.
Ive read some chapters on this and the documentation on msdn and got everything configured how i like.
however, i would like each user to be validated/activated by email before they can use the site. Using standard methods by sending an email to the address on their account with a guid link - the account then gets activated when they click the link in the email.
While im quite happy to code this up myself im pretty surprised that there isnt any support 'out of the box'. One problem i see is that there is no 'activated' flag in the aspnet_users table. I gather i can implement this by adding my own custom fields to the profile via web.config.
Anyone have any advice or workarounds on this matter?
Thanks in advance for any contributions.
---Guy H ( ---
|
|
|
|
|
|
Thanks for your reply mark. Ive been skirting around the tables and noticed this flag in aspnet_membership.
The book ive been reading doesnt really go very deep into the membership stuff so i think maybe some more research is going to be beneficial.
---Guy H ( ---
|
|
|
|
|
Hi
The gist of my problem is that I want to bind an ASP.NET ListBox to a List< T > and have the Value field populated by a property of an object in the List and the Text field populated by the result of the call ToString() on the object in the List (the format of which is dictated by the DataTextFormatString propery of the ListBox ):
I have two classes
PersonInfo - has properties PersonId / FirstName / LastName. This class implements IFormattable allowing customized string representation of any instantiated object.
PersonInfoList which derives from List< PersonInfo > (so stores objects of type PersonInfo ).
I want to use PersonInfoList as the DataSource to a ListBox:
PersonInfoList pil = new PersonInfoList();<br />
ListBox1.DataSource = pil;<br />
ListBox1.DataTextFormatString = "{0:l, f}";
ListBox1.DataBind();
By not specifying the DataTextField or DataValue field, the IFormattable ToString() method is called on each PersonInfo object in the PersonInfoList and both the Text and Value properties are populated with [LastName], [FirstName] as expected.
The problem is that I want the Value field to contain PersonId and the Text field to contain the Person's name (formatted) as above.
If I add PersonId to the ListBox1.DataValueField and do not specify a value for ListBox1.DataTextField , the PersonId is used for both Text and Value .
The only way that I have found around this is to add a Me property the PersonInfo class:
public PersonInfo Me<br />
{<br />
get{ return this; }<br />
}
and then set
ListBox1.DataTextField = "Me";
YUCK! This produces the desired output, but there has to be a better way to do this!
Any ideas would be much appreciated.
Chris
|
|
|
|
|
Hi there,
When a control is not suitable for my need, I might think of customizing the control. So IMHO, in this case you might want to create a custom ListBox control by inheriting from the standard ListBox control and simply override the PerformDataBinding method which is where you can put your own data binding logic.
|
|
|
|
|
Hi
Thanks for the repsonse. Just strikes me as odd that this functionality isn't available out of the box (it very nearly is - just not quite.
I discovered that I can get the functionality by using Dictionary< T > with PersonId as Key and the PersonInfo object as Value (and setting DataTextField="Value" and DataValueField="Key") - but then I can't sort the output by value (as far as I can tell) which is another requirement.
Ah well - gives me a good excuse to dig into the PerformDataBinding method I guess!
Thanks again for your help.
C
|
|
|
|
|
Basically, the ListBox control inherits from the base class ListControl , when data is bound to the control the PerformDataBinding gets executed internally. And this method contains the default logic to build the items collection from the specified data source with the settings like DataTextField, DataValueField and DataTextFormatString. Fortunately, this method is overridable, so you're not happy with the default behavior, you can change it the way you want by overriding this method in your custom control.
In addition, you may consider using the generic Dictionary as you discovered only when you bind data to the control. By this I mean, you can sort data with the List generic collection, you then copy it to the Dictionary and bind it to the control. However, this step is unnecessary to me. Adding a public property like Me is also an option, but it's not really a good choice IMHO as it requires you to change your object design.
|
|
|
|
|
I agree that the Me property is less than desirable.
Interesting point about transferring it to a Dictionary prior to binding. Hadn't thought of that!
Ultimately, I'll probably just follow your advice and subclass ListBox and any other controls that I need to use this in.
As I said, it strikes me as odd that this isn't available out of the box. It's surely not that unusual a requirement to be able to use a property of an object as the Value field and the ToString() representation of that object as the Text field and to be able to acheive this via data binding.
Any way, your feedback has been most useful and has given me something to dig into. So many thanks for your time.
C
|
|
|
|
|
Hi Friends,
I want to encrypt some numeric value .. So anybody can help me providing some encryption function ... or any kind of help for encrypt a string/numeric values ...
Thanks in advance
Arindam,
|
|
|
|
|
Imports System.Security.Cryptography<br />
Imports System.IO<br />
Imports System.Text <br />
<br />
Private Shared KEY_64() As Byte = {42, 16, 93, 156, 78, 4, 218, 32}<br />
Private Shared VAL_64() As Byte = {55, 103, 246, 79, 36, 99, 167, 3}<br />
<br />
Public Shared Function Encrypt(ByVal value As String) As String<br />
Dim CryptoProvider As DESCryptoServiceProvider = New DESCryptoServiceProvider<br />
Dim ms As MemoryStream = New MemoryStream<br />
Dim cs As CryptoStream = New CryptoStream(ms, CryptoProvider.CreateEncryptor(KEY_64, VAL_64), CryptoStreamMode.Write)<br />
Dim sw As StreamWriter = New StreamWriter(cs)<br />
sw.Write(value)<br />
sw.Flush()<br />
cs.FlushFinalBlock()<br />
ms.Flush()<br />
Return Convert.ToBase64String(ms.GetBuffer, 0, ms.Length)<br />
End Function
Pathan
|
|
|
|
|
Hi there:
.NET have System.Security.Cryptography namespace to do that...
<< >>
|
|
|
|
|
|
Hi All,
I am using .net FrameWork 1.1. In FrameWork 2.0, there is Attribute "DefaultButton" in the form and Panel tag .
How can I implement this in ,net 1.1 version. Whenever the user hits the ENTER key from anywhere in the form, the form should postback to the server.
Anybody can help me reg this?
Regards,
Jay
|
|
|
|
|
|
Hi,
Is it the only way in .net 1.1? Because I am using many forms in my project. I wish to allow the user to submit the form when he hits the enter key.
The form may contains 10 text boxes. Is there any other asp.net command to to submit the form without using JS?
Regards,
Jay
|
|
|
|
|
If the Submit button is the first button on the page and there is more than one textbox then that button will be considered "Clicked" when the user hits the "Enter" key.
Cleako
|
|
|
|