in first dropdown i select 1 and in second dropdown select 7 then
i want total number like
1
2
3
4
5
6
7
if i select 2 from first dropdown and 5 from second one then
2
3
4
5
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sunny SharmaPosted Sep 6, 2013, 2:55 AM
Well, I don't know what else you're trying to update or insert but I think this piece of code you want to be modified:
------------------------------------------------------------------
str = "insert into School values (" + ddlStudentName.SelectedValue + ","+ddlcrc.SelectedValue+","+ddlECName.SelectedValue+",'" + TextBox5.Text + "','" + user + "','" + date + "')";
---------------------------------------------------------------------------------------------
If that is the case and the table schema is sa,e as you've mentioned in your reply, like:
----------------------------------
id school standard
1 ssh 1
2 ssh 2
3 ssh 3 // list i got
4 ssh 4
-----------------------------------
then modify your insert string like:
foreach(int i in standard) //here I assume "standard" is the list of integers you generated
{
str = "insert into standard_master values(DEFAULT,'schoolName',i'); // here put i in quote if datatype is varachar
command.CommandText = str;
command.ExecuteNonQuery();
}
Prasenjit DeyPosted Sep 6, 2013, 2:46 AM
Hardik PatelPosted Sep 6, 2013, 2:28 AM
i got the list but i want to insert it with my below code
if i got list like
Standard
1
2
3
4
i want to insert it into database like
id school standard
1 ssh 1
2 ssh 2
3 ssh 3 // list i got
4 ssh 4
how to use it with my code
Prasenjit DeyPosted Sep 6, 2013, 2:11 AM
int strts = Convert.ToInt32(DropDownList1.SelectedValue);
int ends = Convert.ToInt32(DropDownList2.SelectedValue);
List
for (int i = strts; i <= ends; i++)
{
lstStore .Add(i);
}
foreach( int f in lstStore )
{
Response.Write(f.ToString());
}
Sunny SharmaPosted Sep 6, 2013, 2:04 AM
You can do it like this:
List
int num1=0,num2=0;
num1=Convert.ToInt32(dropdownlist1.SelectedText); //or SelectedValue as per your code
num2=Convert.ToInt32(dropdownlist2.SelectedText);
for(int i=num1;i<=num2;i++)
{
list.Add(i);
}
now do whatever you want to with list.
Hope it helps!
Happy Coding :)
Prasenjit DeyPosted Sep 6, 2013, 2:01 AM