DropDropDownList Selected Value
<p>I currently have a dropdownlist which is populated via an SQLDataSource from the Module Table in my database.
The Module Table has 3 fields: ModuleID, ModuleName and CourseID.
Here is my code for my dropdownlist;</p>

<pre><code>&lt;asp:DropDownList ID="ModuleDropDownList" 
                        style="position:absolute; top: 35px; left: 152px;" runat="server" 
                        DataSourceID="SqlDataSource2" DataTextField="ModuleName" 
                        AutoPostBack="True" 
                        &gt;

&lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                        ConnectionString="&lt;%$ ConnectionStrings:RegisterConnectionString %&gt;" 
                        SelectCommand="SELECT DISTINCT * FROM [Module] WHERE ([CourseID] = @CourseID)"&gt;
                        &lt;SelectParameters&gt;
                            &lt;asp:ControlParameter ControlID="CourseDropDownList" Name="CourseID" 
                                PropertyName="SelectedValue" Type="Int32" /&gt;
                        &lt;/SelectParameters&gt;

                    &lt;/asp:SqlDataSource&gt;
</code></pre>

<p>When the user clicks a Save button on the page then the selected value in the dropdownlist is recorded in another database table called Attendance with a field ModuleID, however the problem I am having is to display all the ModuleName in the dropdownlist but depending on the selected ModuleName it will add the respective ModuleID to the ModuleID field in the Attendance table.
Here is my code which saves the selected value in the dropdownlist to the ModuleID field in the Attendance Table;</p>

<pre><code>                command = new SqlCommand("INSERT INTO Attendance(Present, Date, StudentID, StudentName, ModuleID) VALUES (@Attendance, @Date, @StudentID, @StudentName, @ModID)", connection);
                command.Parameters.AddWithValue("@Attendance", attendance);
                command.Parameters.AddWithValue("Date", DateTime.Now);
                command.Parameters.AddWithValue("@StudentID", StudentID);
                command.Parameters.AddWithValue("@StudentName", StudentName);
                command.Parameters.AddWithValue("@ModID", ModuleDropDownList.SelectedValue);
</code></pre>

<p>However the ModuleID field in the Attendance table has the data type Int so I need a way of recording the ModuleID in the Attendance table based on the ModuleName chosen from the dropdownlist.
Any help is much appreciated, thanks in advance!</p>
