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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Prasenjit DeyRank #6,279 · 271 reputationPosted Sep 5, 2013, 10:01 PM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Sep 5, 2013, 10:04 PM EDT
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 DeyRank #6,279 · 271 reputationPosted Sep 5, 2013, 10:11 PM EDT
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());
}
Hardik PatelRank #4,439 · 343 reputationPosted Sep 5, 2013, 10:28 PM EDT
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 DeyRank #6,279 · 271 reputationPosted Sep 5, 2013, 10:46 PM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Sep 5, 2013, 10:55 PM EDT
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();
}