[Mono-bugs] [Bug 42246][Nor] New - Problem displaying data in dropdownlist
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Fri, 2 May 2003 06:22:16 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by gonzalo@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=42246
--- shadow/42246 Fri May 2 06:22:16 2003
+++ shadow/42246.tmp.19092 Fri May 2 06:22:16 2003
@@ -0,0 +1,71 @@
+Bug#: 42246
+Product: Mono/Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: System.Web
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: gonzalo@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Problem displaying data in dropdownlist
+
+As reported in mono-list:
+Here is another problem I ran into. I am populating a dropdownlist with
+fields from a SQL file. I give it the DataTextField, but it displays not
+the name in the ddl but the data type, like:
+System.Data.Common.DbDataRecord. Here is the listing:
+----------------------------------------------------------------------------
+-----
+<%@ Page Language="C#" %>
+<%@ Import Namespace="System" %>
+<%@ Import Namespace="System.Data" %>
+<%@ Import Namespace="System.Data.SqlClient" %>
+
+<script runat="server">
+public void Page_Load(Object Sender, EventArgs e)
+{
+ SqlDataReader reader;
+ string connectionString =
+ "Server=SERVER;" +
+ "Database=pubs;" +
+ "User ID=sa;" +
+ "Password=gon23zo;";
+ SqlConnection dbcon;
+ dbcon = new SqlConnection(connectionString);
+ dbcon.Open();
+ SqlCommand dbcmd = dbcon.CreateCommand();
+ string sql =
+ "SELECT au_fname, au_lname " +
+ "FROM Authors";
+ dbcmd.CommandText = sql;
+ reader = dbcmd.ExecuteReader();
+
+ ddlAuthors.DataSource = reader;
+ ddlAuthors.DataTextField = "au_lname";
+ ddlAuthors.DataBind();
+
+ // clean up
+ reader.Close();
+ dbcon.Close();
+ }
+</script>
+
+<Html>
+<Body>
+<H2>Testing Sql</H2>
+<form runat="server">
+
+<asp:DropDownList ID="ddlAuthors" runat="Server" />
+
+</form>
+</Body>
+</Html>
+----------------------------------------------------------------------------
+--------