Groups | Blog | Home
all groups > asp.net > april 2004 >

asp.net : A problem with DataList???Help!!!


Àä×ÔȪ
4/1/2004 11:57:18 PM
I insert a DataList and a Datagrid in a page:

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 103; LEFT: 456px; POSITION:
absolute; TOP: 56px"runat="server"></asp:DataGrid>

<asp:DataList id="DataList2" style="Z-INDEX: 104; LEFT: 280px; POSITION:
absolute; TOP: 88px"runat="server">
<ItemTemplate>
<asp:Label id=Label6 runat="server" Text='<%#
DataBinder.Eval(Container.DataItem,"½òÌùÀà±ð") %>'></asp:Label>
</ItemTemplate>
<AlternatingItemTemplate>
<FONT face="ËÎÌå"></FONT>
</AlternatingItemTemplate>
</asp:DataList>

Then I bind data from sqlserver2000 like this;

private void Page_Load(object sender, System.EventArgs e)
{
System.Data.SqlClient.SqlConnection conn=new
System.Data.SqlClient.SqlConnection();
conn.ConnectionString="server=brhhk;user=sa;pwd=hk;database=br";
conn.Open();
System.Data.SqlClient.SqlCommand cmd=null;
cmd=new System.Data.SqlClient.SqlCommand("SELECT * FROM kyjt where
username='"+User.Identity.Name.Trim()+"'",conn);
System.Data.DataSet dataset=new DataSet();;
System.Data.SqlClient.SqlDataAdapter adapter=new
System.Data.SqlClient.SqlDataAdapter(cmd);
System.Data.DataTable t=new DataTable();
adapter.Fill(t);
DataGrid1.DataSource=t;
DataGrid1.DataBind();
DataList2.DataSource=t;
DataList2.DataBind();
adapter.Dispose();
conn.Close();
}
I bind the DataGrid and DataList with the same DataSource.
The DataGrid can property display the data i wanted,
But the DataList only display the column of 1,3,5,7.
I'm hurry for the program.I will great thanks if any one helps.

Àä×ÔȪ
4/2/2004 12:08:37 AM
I'm sorry ,the problem is the DataList only diskplay the Rows of 1,3,5,7.Not
the column.
"Àä×ÔȪ" <brhhk@swnu.edu.cn> дÈëÏûÏ¢
news:O5FT$IAGEHA.3540@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button