can we use a single veriable for diferent values to print in inline code at the same time. i am using datalist_itembound event i want to print totRent2 of different cars using the same variable.
--------------------------------------------------------------------------------------------
protected
void DataList3_ItemDataBound(object sender, DataListItemEventArgs e){
int it= e.Item.ItemIndex; int id =(int) DataList3.DataKeys[it]; Bll bll = new Bll(); DataSet ds = bll.sendSelectedCarID(id); foreach (DataRow rows in ds.Tables[0].Rows){
// lbtest.Text=rows[].ToString(); DateTime start = DateTime.Parse(lbsdate.Text); DateTime end = DateTime.Parse(lbrdate.Text);totdays = (end - start).Days;
DateTime ret = DateTime.Parse(lbrtime.Text); DateTime star = DateTime.Parse(lbstime.Text); int l = (ret - star).Hours; if (l > 2){
totdays = totdays + 1;
}
if ((totdays >= 2) && (totdays <= 6) && (start.Month == 11) || (end.Month == 11) || (start.Month == 12) || (end.Month == 12) || (start.Month == 1) || (end.Month == 1) || (start.Month == 2) || (end.Month == 2) || (start.Month == 3) || (end.Month == 3)){
rent =
Convert.ToInt32(rows["2_6DaysLowSeason"].ToString());
}
else if (totdays >= 7 && totdays <= 13 && (start.Month == 11) && (end.Month == 11) || (start.Month == 12) || (end.Month == 12) || (start.Month == 1) || (end.Month == 1) || (start.Month == 2) || (end.Month == 2) || (start.Month == 3) || (end.Month == 3)){
rent =
Convert.ToInt32(rows["7_13DaysLowSeason"].ToString());
}
else if (totdays >= 14 && (start.Month == 11) && (end.Month == 11) || (start.Month == 12) || (end.Month == 12) || (start.Month == 1) || (end.Month == 1) || (start.Month == 2) || (end.Month == 2) || (start.Month == 3) || (end.Month == 3)){
rent =
Convert.ToInt32(rows["14+DaysLowSeason"].ToString());
}
else if (totdays >= 2 && totdays <= 6 && (start.Month == 4) || (end.Month == 4) || (start.Month == 5) || (end.Month == 5) || (start.Month == 6) || (end.Month == 6) || (start.Month == 7) || (end.Month == 7) || (start.Month == 8) || (end.Month == 8) || (start.Month == 9) || (end.Month == 9) || (start.Month == 10) || (end.Month == 10)){
rent =
Convert.ToInt32(rows["2_6DaysHighSeason"].ToString());
}
else if (totdays >= 7 && totdays <= 13 && (start.Month == 4) && (end.Month == 4) || (start.Month == 5) && (end.Month == 5) || (start.Month == 6) && (end.Month == 6) || (start.Month == 7) && (end.Month == 7) || (start.Month == 8) && (end.Month == 8) || (start.Month == 9) && (end.Month == 9) || (start.Month == 10) && (end.Month == 10)){
rent =
Convert.ToInt32(rows["7_13DaysHighSeason"].ToString());
}
else if (totdays >= 14 && (start.Month == 4) && (end.Month == 4) || (start.Month == 5) && (end.Month == 5) || (start.Month == 6) && (end.Month == 6) || (start.Month == 7) && (end.Month == 7) || (start.Month == 8) && (end.Month == 8) || (start.Month == 9) && (end.Month == 9) || (start.Month == 10) && (end.Month == 10)){
rent =
Convert.ToInt32(rows["14+DaysHighSeason"].ToString());
}
}
tot = rent * totdays;
totRent = tot.ToString();
}
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
//int it = 0; int id = 0; int it = e.Item.ItemIndex;id = (
int)DataList1.DataKeys[it];it++;
Bll bll = new Bll(); DataSet ds = bll.sendSelectedCarID(id); //DataRow row; //row = ds.Tables[0].Rows[0]; foreach (DataRow rows in ds.Tables[0].Rows){
// lbtest.Text=rows[].ToString(); DateTime start = DateTime.Parse(lbsdate.Text); DateTime end = DateTime.Parse(lbrdate.Text);totdays = (end - start).Days;
DateTime ret = DateTime.Parse(lbrtime.Text); DateTime star = DateTime.Parse(lbstime.Text); int l = (ret - star).Hours; if (l > 2){
totdays = totdays + 1;
}
if ((totdays >= 2) && (totdays <= 6) && (start.Month == 11) || (end.Month == 11) || (start.Month == 12) || (end.Month == 12) || (start.Month == 1) || (end.Month == 1) || (start.Month == 2) || (end.Month == 2) || (start.Month == 3) || (end.Month == 3)){
rent =
Convert.ToInt32(rows["2_6DaysLowSeason"].ToString());
}
else if (totdays >= 7 && totdays <= 13 && (start.Month == 11) && (end.Month == 11) || (start.Month == 12) || (end.Month == 12) || (start.Month == 1) || (end.Month == 1) || (start.Month == 2) || (end.Month == 2) || (start.Month == 3) || (end.Month == 3)){
rent =
Convert.ToInt32(rows["7_13DaysLowSeason"].ToString());
}
else if (totdays >= 14 && (start.Month == 11) && (end.Month == 11) || (start.Month == 12) || (end.Month == 12) || (start.Month == 1) || (end.Month == 1) || (start.Month == 2) || (end.Month == 2) || (start.Month == 3) || (end.Month == 3)){
rent =
Convert.ToInt32(rows["14+DaysLowSeason"].ToString());
}
else if (totdays >= 2 && totdays <= 6 && (start.Month == 4) || (end.Month == 4) || (start.Month == 5) || (end.Month == 5) || (start.Month == 6) || (end.Month == 6) || (start.Month == 7) || (end.Month == 7) || (start.Month == 8) || (end.Month == 8) || (start.Month == 9) || (end.Month == 9) || (start.Month == 10) || (end.Month == 10)){
rent =
Convert.ToInt32(rows["2_6DaysHighSeason"].ToString());
}
else if (totdays >= 7 && totdays <= 13 && (start.Month == 4) && (end.Month == 4) || (start.Month == 5) && (end.Month == 5) || (start.Month == 6) && (end.Month == 6) || (start.Month == 7) && (end.Month == 7) || (start.Month == 8) && (end.Month == 8) || (start.Month == 9) && (end.Month == 9) || (start.Month == 10) && (end.Month == 10)){
rent =
Convert.ToInt32(rows["7_13DaysHighSeason"].ToString());
}
else if (totdays >= 14 && (start.Month == 4) && (end.Month == 4) || (start.Month == 5) && (end.Month == 5) || (start.Month == 6) && (end.Month == 6) || (start.Month == 7) && (end.Month == 7) || (start.Month == 8) && (end.Month == 8) || (start.Month == 9) && (end.Month == 9) || (start.Month == 10) && (end.Month == 10)){
rent =
Convert.ToInt32(rows["14+DaysHighSeason"].ToString());
}
}
tot = rent * totdays;
totRent2 = tot.ToString();
}
Replies
Know the answer? Post it — somebody with the same question will find it here.