Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i have 3 table namely USERS, Groups, and Student

private bool BindData(string query)
    {
        try
        {
            String connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
            SqlConnection con = new SqlConnection(connectionString);            
            SqlDataAdapter adapter = new SqlDataAdapter(query, con);
            DataSet ds = new DataSet();
            adapter.Fill(ds);            
            studentDetailsView.DataSource = ds;            
            studentDetailsView.DataBind();
            return true;
        }
        catch
        {
            return false;
        }
    }

the adapter.fill(ds) displays the correct result is shown when debugged but when its time to show in detailview it only displays first record of student against selected group

please suggest me how to display all the student data against selected group.
i have used this to display the data
ASP
<asp:DetailsView><asp:TemplateField HeaderText="LoginID">
                    <ItemTemplate>
                        <asp:Literal ID="litLoginID" runat="server" Text=' <%# Eval("LoginID")  %> ' />
                    </ItemTemplate>
                </asp:TemplateField>


and displayed all the info that is returned by the query
Posted
Updated 24-Feb-13 1:02am
v6
Comments
Sandeep Mewara 23-Feb-13 11:53am    
Try changing this line from this:
<pre lang="c#">studentDetailsView.DataSource = ds;</pre>
to
<pre lang="c#">studentDetailsView.DataSource = ds.Tables[0];</pre>
hinaiqbal 24-Feb-13 6:57am    
thanks
Sandeep Mewara 24-Feb-13 7:12am    
Do share if that works.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900