Error on rendering gridview

mord3th

New Member
I'm having a table in the database with the column \[code\]StudentID\[/code\]. I'm trying to generate a grid view. I can't understand the error generated here in this snapshot. What does the error say and how can I fix it? Please help.
CUyRl.png
The source code:\[code\]<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="StudentID " DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField DataField="StudentID " HeaderText="StudentID " ReadOnly="True" SortExpression="StudentID " /> <asp:BoundField DataField="First Name" HeaderText="First Name" SortExpression="First Name" /> <asp:BoundField DataField="Last Name" HeaderText="Last Name" SortExpression="Last Name" /> <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" /> <asp:BoundField DataField="Email " HeaderText="Email " SortExpression="Email " /> <asp:BoundField DataField="Major" HeaderText="Major" SortExpression="Major" /> <asp:BoundField DataField="Password" HeaderText="Password" SortExpression="Password" /> </Columns></asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\StudentDB.mdf;Integrated Security=True" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Student]"></asp:SqlDataSource>\[/code\]The Select statement:\[code\] SqlConnection conn = new SqlConnection(); conn.ConnectionString = SqlDataSource1.ConnectionString; string str = "SELECT * FROM Student " + " WHERE StudentID = '" + StudentID.Text + "' AND " + " Password = '" + SPassword.Text + "'"; SqlCommand cmdSelect = new SqlCommand(str, conn);\[/code\]
 
Back
Top