Dynamically creating a columns in asp.net gridview -
i doing project on hotels. in booking page room types , availability, , rates have populate on gridview given dates.
below roomtypes in hotel admin page.
image below binding room rates given date.
currently binding data using sql query each cell.so taking time load page.
i need find faster method bind data.
code have using given below.
dim dtx new datatable
/// sql command load roomtypes.
while dr.read dtr = dtx.newrow() dim datearray() string = lbl_checkindate.text.split("/") dim xdt1 new date(cint(datearray(2)), cint(datearray(0)), cint(datearray(1))) dtr("room type") = dr("r_type").tostring dtr("book") = dr("r_id").tostring x = 1 15 tmpdt = left(weekdayname(weekday(xdt1)), 3) & vbnewline & day(xdt1) & " " & left(monthname(month(xdt1)), 3) price = cls_function.gettabledata("select isnull(rent_a,0) rent_a tbl_hotelroom h_id = " & val(request.querystring("hid")) & " , r_id = " & val(dr("r_id").tostring) & " , f_dt <= '" & year(xdt1) & "-" & month(xdt1) & "-" & day(xdt1) & "' , t_dt >= '" & year(xdt1) & "-" & month(xdt1) & "-" & day(xdt1) & "'") if price = nothing dtr(tmpdt) = cls_function.gettabledata("select isnull(rent_a,0) rent_a tbl_hotelroom h_id = " & val(request.querystring("hid")) & " , r_id = " & val(dr("r_id").tostring) & " , f_dt <= '" & year(xdt1) & "-" & month(xdt1) & "-" & day(xdt1) & "' , t_dt >= '" & year(xdt1) & "-" & month(xdt1) & "-" & day(xdt1) & "'") else dtr(tmpdt) = format(price, "n") end if xdt1 = dateadd(dateinterval.day, 1, xdt1) next dtx.rows.add(dtr)
although not clear going guess calling database each of dates room rate. better approach write stored procedure return room rates next x dates given room type. if sproc returns data multiple rows (rather 1 row many columns, trickier sql) business logic manipulation data in format need bind grid.
Comments
Post a Comment