| | |
Textbox and button visible true or false problem
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 40
Reputation:
Solved Threads: 0
hi
I am creating travels project, in left part of my datagrid of my default page i placed all the products such as india tour ,world tour etc and if v click any product it will redirect to itennary page according to their ID's
my problem is i inserted new product as Hotel Booking and i want to place textbox and a button in the itenary page and if v click india tour or world tour i want those textbox and button should be not visible and if v click Hotel booking then those textbox and button should visible
Please solve my problem its urgent.
Thank you in advance
raghu
I am creating travels project, in left part of my datagrid of my default page i placed all the products such as india tour ,world tour etc and if v click any product it will redirect to itennary page according to their ID's
my problem is i inserted new product as Hotel Booking and i want to place textbox and a button in the itenary page and if v click india tour or world tour i want those textbox and button should be not visible and if v click Hotel booking then those textbox and button should visible
Please solve my problem its urgent.
Thank you in advance
raghu
c# Syntax (Toggle Plain Text)
Button2.Visible = false; // to hide button textBox1.Visible = false; // to hide textbox Button2.Visible = true; // to show button textBox1.Visible = false; // to show textbox
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
You haven't given us enough information to give you specific codeing. How do you know what itinery to show in the itinery page? Are you using the query string or session variable? Codeing will be different depending.
The only coding that would always be the same is the snippet Jx_Man gave, inside some kind of if statement, that works out from the ID if the selected item, whether it's a hotel booking or not.
And I would guess you'd put that into the Page_Load event of the itinery page.
The only coding that would always be the same is the snippet Jx_Man gave, inside some kind of if statement, that works out from the ID if the selected item, whether it's a hotel booking or not.
And I would guess you'd put that into the Page_Load event of the itinery page.
Last edited by hollystyles; Feb 11th, 2008 at 9:20 am.
•
•
Join Date: Nov 2007
Posts: 40
Reputation:
Solved Threads: 0
Thanks holly for your reply
with in the itenary page i placed datagrid and the values has been populated from dadatbase according to the selected product whether it is a India tour or world tour
now i placed hotel booking in the product list and when i click i want to place all the texbox and button
just look at my codding
if (!IsPostBack)
{
if (Request.QueryString["CatId"] != null)
{
Session["catid"] = Request.QueryString["CatId"].ToString();
}
else
{
Session["catid"] = "0";
}
fillgrid();
private void fillgrid()
{
DataSet ds = Travel_Product1.return_travel_product_bycatid(Convert.ToInt32(Session["catid"]));
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
dgprodlist.DataSource = ds;
dgprodlist.DataBind();
}
}
}
please try to solve my proble its very urgent
Thank you in advance
raghu
with in the itenary page i placed datagrid and the values has been populated from dadatbase according to the selected product whether it is a India tour or world tour
now i placed hotel booking in the product list and when i click i want to place all the texbox and button
just look at my codding
if (!IsPostBack)
{
if (Request.QueryString["CatId"] != null)
{
Session["catid"] = Request.QueryString["CatId"].ToString();
}
else
{
Session["catid"] = "0";
}
fillgrid();
private void fillgrid()
{
DataSet ds = Travel_Product1.return_travel_product_bycatid(Convert.ToInt32(Session["catid"]));
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
dgprodlist.DataSource = ds;
dgprodlist.DataBind();
}
}
}
please try to solve my proble its very urgent
Thank you in advance
raghu
I'm still not entirely sure what you want to do. I take it english is not your first language?
Are india tour and world tour catagories ?
So I choose a category, then I see a datagrid of tour products, one of which is a hotel booking ? So hotel booking is in the datagrid?
A textbox and button should appear in a datagrid column oposite only the hotel booking product, to the right hand side?
Use the OnItemDataBound event of the datagrid, use the event args to determine if the row is a hotel booking, make the textbox and button visible
Are india tour and world tour catagories ?
So I choose a category, then I see a datagrid of tour products, one of which is a hotel booking ? So hotel booking is in the datagrid?
A textbox and button should appear in a datagrid column oposite only the hotel booking product, to the right hand side?
Use the OnItemDataBound event of the datagrid, use the event args to determine if the row is a hotel booking, make the textbox and button visible
C# Syntax (Toggle Plain Text)
<asp:DataGrid ID="dgprodlist" Runat="server" AutoGenerateColumns="False"> <Columns> <asp:BoundColumn HeaderText="Product" DataField="Product"></asp:BoundColumn> <asp:TemplateColumn> <ItemTemplate> <asp:TextBox ID="txtText" Runat="server"></asp:TextBox> <asp:Button ID="btnButton" Runat="server" Text="Button"></asp:Button> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid>
C# Syntax (Toggle Plain Text)
public class itinerary : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid dgprodlist; //set up some data private string[] products = {"Product 1","Product 2","Hotel Booking"}; private DataTable prodList = new DataTable(); private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if(!IsPostBack) { //Add a column (I don't have your database so I have to mock it up) prodList.Columns.Add("Product"); //add some rows for(int i = 0; i < 3; ++i) { DataRow row = prodList.NewRow(); row[0] = products[i]; prodList.Rows.Add(row); } //Bind the data dgprodlist.DataSource = prodList; dgprodlist.DataBind(); } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); this.dgprodlist.ItemDataBound += new DataGridItemEventHandler(dgprodlist_ItemDataBound); //Wire up the event. Fires on row creation during DataBind() } #endregion private void dgprodlist_ItemDataBound(object sender, DataGridItemEventArgs e) { //Test for rows, don't want to execute code on header item that will cause an exception. if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //Get a reference to the textbox and button control TextBox tb = (TextBox)e.Item.Cells[1].FindControl("txtText"); Button b = (Button)e.Item.Cells[1].FindControl("btnButton"); //If it's the hotel booing product show the controls, else hide them if(e.Item.Cells[0].Text == "Hotel Booking") { tb.Visible = true; b.Visible = true; } else { tb.Visible = false; b.Visible = false; } } } }
Last edited by hollystyles; Feb 11th, 2008 at 10:57 am.
•
•
Join Date: Nov 2007
Posts: 40
Reputation:
Solved Threads: 0
Thanks holly for that codding but you almost got my problem
yes indian tours,world tours and even hotel booking is also category,
now, when i click india tour or world tour it just redirect to itenary page and display images and text in datalist from database according to their categories ID, up to here its running perfectly.
my problem is when i click hotel booking it should redirect to the same itenary page and there i want textbox and buttons
and those textbox and button should be visible false when when i click india tour or world tour and it should visible true when i click hotel booking.
I hope you may understand,
by the way, i dont want to display textbox and button in the datagrid
Thank you in advance
raghu
yes indian tours,world tours and even hotel booking is also category,
now, when i click india tour or world tour it just redirect to itenary page and display images and text in datalist from database according to their categories ID, up to here its running perfectly.
my problem is when i click hotel booking it should redirect to the same itenary page and there i want textbox and buttons
and those textbox and button should be visible false when when i click india tour or world tour and it should visible true when i click hotel booking.
I hope you may understand,
by the way, i dont want to display textbox and button in the datagrid
Thank you in advance
raghu
Last edited by raghu.8; Feb 12th, 2008 at 6:25 am.
Right, so just set the visible properties of the necessary controls in the page load event handler of itenary.aspx
I don't get what the problem is ??????
I don't get what the problem is ??????
•
•
Join Date: Nov 2007
Posts: 40
Reputation:
Solved Threads: 0
just look at my coding where i written in the page load event
but i am getting error
raghu
C# Syntax (Toggle Plain Text)
protected void Page_Load() { int id = int.Parse(Request.QueryString["ID"]); if (id == "hotel booking") //etc... { TextBox1.Visible = true; Button1.Visible = true; } else { TextBox1.Visible = false; Button1.Visible = false; }
but i am getting error
raghu
Last edited by raghu.8; Feb 12th, 2008 at 6:36 am.
Post the error then, I 'm afraid I left my crystal ball at home. 
Well actually I can hazard a guess. You cast the QueryString variable to integer, then you try and comapre it to a string lilteral ??
if (id == "hotel booking")
is your problem, id is an integer variable, "hotel booking" is a string literal... duh!
options:
Pass "hotel booking" in the QueryString instead or aditionally
Look up the catagory text in the DB using the id
hard code the id (bad bad bad...)
What should really do is make a ups_IsHotelBooking stored procedure in the DB passing your id to it and get it to return 1 for true and 0 for false and set the textbox and button visibility accordingly.

Well actually I can hazard a guess. You cast the QueryString variable to integer, then you try and comapre it to a string lilteral ??
if (id == "hotel booking")
is your problem, id is an integer variable, "hotel booking" is a string literal... duh!
options:
Pass "hotel booking" in the QueryString instead or aditionally
Look up the catagory text in the DB using the id
hard code the id (bad bad bad...)
What should really do is make a ups_IsHotelBooking stored procedure in the DB passing your id to it and get it to return 1 for true and 0 for false and set the textbox and button visibility accordingly.
Last edited by hollystyles; Feb 12th, 2008 at 6:44 am.
![]() |
Similar Threads
- GridView cell textbox.Visible = true (ASP.NET)
- datagrid, innertext, javascript, database update (ASP.NET)
- Why javascript does not work on firefox? (JavaScript / DHTML / AJAX)
- error on page!! Cannot solve!!Help (ASP.NET)
- Validation help (Visual Basic 4 / 5 / 6)
- Validation difficulties *sigh* (ASP.NET)
Other Threads in the C# Forum
- Previous Thread: Shell() command line
- Next Thread: ComboBox Item selection
| Thread Tools | Search this Thread |
.net access algorithm angle array barchart bitmap box broadcast c# capturing check checkbox client combobox control conversion convert csharp custom database datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum event excel file firefox form format forms function gdi+ httpwebrequest image index input install java label leak libraries list listbox mandelbrot math monodevelop mouseclick msword mysql operator path pause photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox round server sleep socket sql statistics stream string table tcpclientchannel text textbox thread time timer update usercontrol validation virtualization visualbasic visualstudio webbrowser windows winforms wpf xml






