<asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="false">
</asp:GridView>







<connectionStrings>
    <add name="MyConnectionString" connectionString="conn_string" providerName="System.Data.SqlClient"/>
  </connectionStrings>







<asp:SqlDataSource ID="sdsGrid" runat="server"
  ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
  SelectCommand="select C.ClassId, C.ClassDisplayName FROM Class C"  />







<asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="false" 
        DataSourceID="sdsGrid">
        <Columns>
            <asp:TemplateField HeaderText="Class">
                <ItemTemplate>
                    <asp:Label ID="lblClassName" runat="server" Text='<%#Eval("ClassDisplayName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Teacher">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlTeacher" runat="server"></asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

  
    <asp:SqlDataSource ID="sdsGrid" runat="server"
  ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
  SelectCommand="select C.ClassId, C.ClassDisplayName FROM Class C"  />






<asp:SqlDataSource ID="sdsTeacher" runat="server"
  ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
  SelectCommand="SELECT ([TeacherFirstName] + ' ' + [TeacherLastName]) as TeacherName  FROM [TeacherDetails]">  
  </asp:SqlDataSource>







<asp:GridView ID="gvTest" runat="server" AutoGenerateColumns="false" 
        DataSourceID="sdsGrid">
        <Columns>
            
            <asp:TemplateField HeaderText="Class">
                <ItemTemplate>
                    <asp:Label ID="lblClassName" runat="server" Text='<%#Eval("ClassDisplayName") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Teacher">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlTeacher" runat="server" DataSourceID="sdsTeacher" DataTextField="TeacherName"></asp:DropDownList>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

  
    <asp:SqlDataSource ID="sdsGrid" runat="server"
  ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
  SelectCommand="select C.ClassId, C.ClassDisplayName FROM Class C"  />

  <asp:SqlDataSource ID="sdsTeacher" runat="server"
  ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"
  SelectCommand="SELECT ([TeacherFirstName] + ' ' + [TeacherLastName]) as TeacherName  FROM [TeacherDetails]">  
  </asp:SqlDataSource>










Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, April 30, 2014

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250