my next problem is:-
what will be the code if same work i've to do with 2 columns say facility(which is i've done) and aminity...
hotel_id hotel_name country facility aminity
-----------------------------------------------------------------------
1 taj india 1,2 2,3
and if i don't want to select individual integer(say "2" from 2,3) and i've to select whole numbers in one time(say click on "2,3") to check all the information of both rows "2" & "3"..
so what will be the code in "GridView1_RowDataBound" event in which i am already using code for facility column..?
please give me answer of this problem..
thank you..

Rahul BhattPosted Jul 20, 2012, 8:15 AM
When you visible false your GridView HeaderRow then first always check
Table has value or not
If table has grater then 0 value then n then visible false header row
Change your code as folloiwng way
if (dst.Tables[0].Rows.Count > 0)
{
GridView2.HeaderRow.Cells[0].Visible = false;
GridView2.HeaderRow.Cells[1].Visible = false;
GridView2.HeaderRow.Cells[2].Visible = false;
}
Priyank KharePosted Jul 20, 2012, 8:44 AM
Rahul BhattPosted Jul 20, 2012, 8:40 AM
Priyank KharePosted Jul 20, 2012, 8:18 AM
i've solve my last problem. so please donot waste your time on that problem...
i've another 2 queries....
1. my gridview look like this:-
select delete editfield hotel_id hotel_name country facility aminity
------------------------------------------------------------------------------------------------------
chkbox checkbx edit 1 taj india 1,2 2,3
in this gridview "autogeneratedcolumns are true".. that is why 1st 3 columns coming from start. i wants these 3 columns end of all the columns... like below:-
hotel_id hotel_name country facility aminity select delete editfield
------------------------------------------------------------------------------------------------------
1 taj india 1,2 2,3 chkbox checkbx edit
remember sir, these 3 columns are template field & autogeneratedcolumns are true.
how can i do that?
please reply me as soon as possible..
thankyou.
Priyank KharePosted Jul 20, 2012, 7:28 AM
my project is working properly, but there is a error(Object reference not set to an instance of an object.) during execution..:-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.QueryString["AId"] != null)
{
amenityhotel();
}
else if (Request.QueryString["RoomType"] != null)
{
amenitiyroom();
}
else
{
BindData();
}
}
}
public void amenitiyroom()
{
string HotelName = Request.QueryString["HotelName"].ToString();
string Aid = Request.QueryString["Aids"].ToString();
string roomtype = Request.QueryString["RoomType"].ToString();
string ConnectionServer = ConfigurationManager.AppSettings.Get("ConnectionServer");
string sConn = clsdb.DecryptData(ConfigurationManager.AppSettings.Get("ConnectionString"));
SqlConnection con = new SqlConnection("Server=" + ConnectionServer + ";" + sConn);
con.Open();
DataSet dst = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select Aid,HotelName,AmenityType,Amenity from Infl_HotelInventory_Amenities where Aid in (" + Aid + ") and HotelName='" + HotelName + "' and RoomType='" + roomtype + "'", con);
da.Fill(dst, "Infl_HotelInventory_Amenities");
GridView2.DataSource = dst;
GridView2.DataBind();
GridView2.HeaderRow.Cells[0].Visible = false; --> in this line error
GridView2.HeaderRow.Cells[1].Visible = false;
GridView2.HeaderRow.Cells[2].Visible = false;
foreach (GridViewRow row in GridView2.Rows)
{
row.Cells[0].Visible = false;
row.Cells[1].Visible = false;
row.Cells[2].Visible = false;
}
con.Close();
}
whats wrong with this code..?
i think there is something wrong in the "select query"..
please tell me what is the right select query in which 3 conditions are coming..
if it is not, then what is right code..?
please reply me..
thank you
Priyank KharePosted Jul 20, 2012, 6:14 AM
gr8..
it is working..thank you so much..
i'll get back to you with in few min...because i've just a few more queries.but let me check this properly once again..
then i'll tell you..
thank you so much..
Rahul BhattPosted Jul 20, 2012, 5:49 AM
USING in insetad of equal to
If you pass single record then use Fid = " + FID + "
If you pass multiple value then use Fid in (" + FID + ")
SqlCommand cmd = new SqlCommand("select Fid,hotel_name,FacilityType,FacilityName from Infl_HotelInventory_Facility where Fid in (" + FID + ") and hotel_name='" + HotelName + "'", con);
Change you query and let me know your feedback
Priyank KharePosted Jul 20, 2012, 5:40 AM
the values are coming like this:-
hotel_id hotel_name country facility aminity
-----------------------------------------------------------------------
1 taj india 1,2 2,3
but problem is that when i clicked on it(say 1,2), then it gives error (Conversion failed when converting the varchar value '1,2' to data type int.) beacuese there is no value like 1,2 in a single row.. it 2 different values(in one row record for "1" & in 2nd for "2").
so my question is there any possiblity that if we click on(1,2) then it should be split in individual digit then display thier respective rows(like record for 1 in a row & record for 2 in next row)..
please solve my this problem too.
thank you
Rahul BhattPosted Jul 20, 2012, 4:18 AM
For that,
You need to change RowDataBound Event in Hotelmaster
Need to Added Facility and Amenities Hyperlink
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string facilityIDs = e.Row.Cells[16].Text;
string AminitiesIDs = e.Row.Cells[17].Text;
string hotelname = e.Row.Cells[1].Text;
// For Display hyperlink in Facility Filed
string facilityvalue = "";
facilityvalue = facilityvalue + "" + facilityIDs + "" + ",";
e.Row.Cells[16].Text = facilityvalue;
// For Display hyperlink in Aminities Filed
string Aminitiesvalue = "";
Aminitiesvalue = Aminitiesvalue + "" + AminitiesIDs + "" + ",";
e.Row.Cells[17].Text = Aminitiesvalue;
}
}
Need to create one Aminities Page same as Facilities Page for Display Amities Value
In Facility Page Change select Query as folloiwng way
SqlCommand cmd = new SqlCommand("select Fid,hotel_name,FacilityType,FacilityName from Infl_HotelInventory_Facility where Fid in (" + FID + ") and hotel_name='" + HotelName + "'", con);
Full Function
public void faciltity()
{
string HotelName = Request.QueryString["HotelName"].ToString();
string FID = Request.QueryString["Fid"].ToString();
string ConnectionServer = ConfigurationManager.AppSettings.Get("ConnectionServer");
string sConn = clsdb.DecryptData(ConfigurationManager.AppSettings.Get("ConnectionString"));
SqlConnection con = new SqlConnection("Server=" + ConnectionServer + ";" + sConn);
con.Open();
SqlCommand cmd = new SqlCommand("select Fid,hotel_name,FacilityType,FacilityName from Infl_HotelInventory_Facility where Fid in (" + FID + ") and hotel_name='" + HotelName + "'", con);
DataSet dst = new DataSet("EmpDs");
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dst, "Infl_HotelInventory_Facility");
GridView1.DataSource = dst;
GridView1.DataBind();
con.Close();
}