Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

How to get a combobox selected value in integer through sqldatasource

$
0
0

I have had a gridview updating marks of homeworks students did.

It was working fine . But my students  checking the homeworks said  when they try to sort the gridview according to students numbers. It wasn't sorting correct.

Because i set the students numbers colum as string in database

Then i changed my access database tables design correcting the stundents number  as integer

But then i couldn't make the code work

This is my sqldatasource code  taking the student's numbers as a paramater from a combobox

IDh is automatic key number in a table where all homeworks are stored.

There are 3 tables in access database

allhomeworks - where all marks of homeworks checked are stored

allstudents list of all students

hwckeckers list of students checking homeworks

everbody iscombobox. It all students in a hwcheckers list

everydate is a combobox. It has all dates a hwchecker checked homeworks.

 

<asp:SqlDataSourceID="SqlDataSource1"runat="server"CancelSelectOnNullParameter="false"

ConnectionString="<%$ ConnectionStrings:homeworksConnectionString3 %>"

DeleteCommand="DELETE FROM [Allhomeworks] WHERE ([Allhomeworks].[IDh] = @IDh)"

ProviderName="<%$ ConnectionStrings:homeworksConnectionString3.ProviderName %>"

 SelectCommand="Select [Allhomeworks].[IDH],[Allstudents].[Name],[Allstudents].[Surname],[Allhomeworks].[StudentNo],[Allhomeworks].[DateofHw],[Allhomeworks].[Mark],[Allhomeworks].[Hwchecker] from [Allhomeworks] INNER JOIN [Allstudents] ON [Allhomeworks].[StudentNo]= [Allstudents].[StudentNo] Where  (([Allhomeworks].[Hwchecker] =@Hwchecker) and ([Allhomeworks].[StudentNo]=@StudentNo or @StudentNo='%') and ([DateofHw]=@DateofHw or @DateofHw='%')) Order by [DateofHw]"

 UpdateCommand="UPDATE Allhomeworks SET Mark=@Mark where (IDh=@IDh)">

<UpdateParameters>
<asp:ParameterName="Mark"Type="String"/>

<asp:ParameterName="IDh"Type="Int16"/></UpdateParameters>
<SelectParameters>                       

<asp:ControlParameterControlID="Label6"ConvertEmptyStringToNull="true"Name="Hwchecker"PropertyName="Text"Type="String"/

<asp:ControlParameterControlID="everybody"ConvertEmptyStringToNull="true"Name="StudentNo"PropertyName="SelectedItem.Value"Type="Int16" />             

<asp:ControlParameterControlID="everydate"ConvertEmptyStringToNull="true"Name="DateofHw"PropertyName="SelectedItem.text"Type="String"/>

 </SelectParameters>

</asp:SqlDataSource>

when the StudentNo was text in Access database

with the code

<asp:ControlParameterControlID="everybody"ConvertEmptyStringToNull="true"Name="StudentNo"PropertyName="SelectedItem.text"Type="String" />            

the page was working

Could someone give me a help about this ?

 


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>