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

Button2.Visible = false; // to hide button
textBox1.Visible = false; // to hide textbox

Button2.Visible = true; // to show button
textBox1.Visible = false; // to show textbox

Thanks for your reply Jx_man
i know that codding but i want codding for particular selected product in datagrid
just read my question properly please

commented: Well then make it easier to read your question. It's very confusing! +0

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.

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

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

<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>
						&nbsp;
						<asp:Button ID="btnButton" Runat="server" Text="Button"></asp:Button>
					</ItemTemplate>
				</asp:TemplateColumn>
				
			</Columns>
		</asp:DataGrid>
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;
				}
			}
		}
	}

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

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 ??????

just look at my coding where i written in the page load event

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

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.

Sorry i am getting error near
if (id == "world tour")
Error 1 Operator '==' cannot be applied to operands of type 'int' and 'string'

That's right the variable id is an integer, "world tour" is a string literal you cannot apply the == operator to these different types.

I can see you are either very very green or a forum troll. If the former you need to get a book on basic programming. One that starts from the beginning explaining types and stuff. If the latter I'm done here.

actually i was totally confused
some times mistake happens;)

still i am getting the same error,when i given hotel booking ID

You're very close. You have the ID, you need a function in itenary.aspx.cs you can pass the ID too, the function should look the ID up and see if it's the hotel booking catagory and return true or false

public class itinery
{
    //all your existing code blah...
    private bool IsHotelBooking( int catId)
    {
        //connect to db pass catId as parameter
        //somrthing like string catName = command.ExecuteScalar();
       if(catName == "hotel booking")
           return true;
        else
            return false;
    }

still i am getting the same error,when i given hotel booking ID

Don't put the hotel booking id in quotes (I'm guessing that's what you've done). And hard coding an ID into your program logic is very poor, but I guess there's time for that later when you've learned more.

Is there any posible that i can attach my sample project to this reply box so that you can understand
raghu

I do understand. But yes you can attach it. Click the Go Advanced button below the reply box. You'll get a bigger editor. SCroll the page down a bit and there's a manage attachments button.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.