Showing posts with label grid. Show all posts
Showing posts with label grid. Show all posts

Friday, March 16, 2012

Passing a variable

Hello

Just a quick question. I have a hyperlink when clicked transfers a variable to another page and populates a grid view but how would i get this variable to be displayed as the page title

cheers

bigyawn_hippo:

Just a quick question. I have a hyperlink when clicked transfers a variable to another page and populates a grid view but how would i get this variable to be displayed as the page title

Is the variable be transfered by query string?

If so you can do this in the page_load event

//assume query string is called titleif (Request.QueryString["title"] !=null){//set to form caption this.Page.Title = Request.QueryString["title"].ToString();}

Hi

its a query string i am trying to display, but i am using VB code will it be different from the code u ve given

cheers


try this:


if !(Request.QueryString("title")) isnull then
this.Page.Title = Request.QueryString("title").ToString();


Here is the VB equivalent:

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not String.IsNullOrEmpty(Request.QueryString("title"))Then Page.Title = Request.QueryString("title")End If End Sub

Here is the VB equivalent

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not String.IsNullOrEmpty(Request.QueryString("title"))Then Page.Title = Request.QueryString("title")End If End Sub

Hi

I placed the code in the vb file but the title of the page remains Untitled

I change "title" to the name of the field that i want it to display should it be somthing else

cheers


if you type yourpage.aspx?title=SomeTitle in your browser, the code I posted should work. Is there something I'm missing here? Are you doing it differently somehow?


Have you set a header control on the aspx page: <head runat"server"> instead of just <head> ?


These may be reasons for which it doesn't wotk

1. You didn't put that method posted few lines up in Page_Load

2. Your querystring do not exist or have another name


hi

I ve set my head to runat server but the code is still not working, i m new to asp so please have paitence but i ve inserted that code u suggested but it causes more errors could you give me the code from ur aspx file.

cheers


Sure:

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> </div> </form></body></html>

And code behind:

PartialClass _DefaultInherits System.Web.UI.PageProtected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not String.IsNullOrEmpty(Request.QueryString("title"))Then Page.Title = Request.QueryString("title")End If End SubEnd Class

if still the top solution did not worked ( i dont know how come it did not ) for u then try this

in first page on button click

Response.Redirect("test.aspx?qtitle =bigyawn");

in the second page codebehind in page load

// in C#

querytitle =Convert.ToString(Request.QueryString["qtitle "]);

in vb

If Not String.IsNullOrEmpty(Request.QueryString("qtitle"))Then
querytitle = Request.QueryString("qtitle") wherequerytitle will be a public string

in aspx page just write like this :

<HTML>
<HEAD>
<title><%=querytitle %></title>

Passing a variable in the onLoad event.

I have a data grid with multiple rows. Each row has a drop down box. I need
it to select the correct item for each row. What I am trying to figure out,
is can I pass a value to the onLoad event for the dropdownlist?

OnLoad="loadDefault(Container.DataItem("dropValue"))"Are you trying to put a selected index?

"Robin Bonin" <robin@.guavatools.com> wrote in message
news:Sr6dnWpfNfAlKIiiXTWJiA@.eatel.net...
> I have a data grid with multiple rows. Each row has a drop down box. I
need
> it to select the correct item for each row. What I am trying to figure
out,
> is can I pass a value to the onLoad event for the dropdownlist?
> OnLoad="loadDefault(Container.DataItem("dropValue"))"
I know the value of the selectedIndex, and that is what I'm trying to
select.

"Cristian Suazo" <crillus7@.hotmail.com> wrote in message
news:O$93Kq9SDHA.1724@.TK2MSFTNGP10.phx.gbl...
> Are you trying to put a selected index?
> "Robin Bonin" <robin@.guavatools.com> wrote in message
> news:Sr6dnWpfNfAlKIiiXTWJiA@.eatel.net...
> > I have a data grid with multiple rows. Each row has a drop down box. I
> need
> > it to select the correct item for each row. What I am trying to figure
> out,
> > is can I pass a value to the onLoad event for the dropdownlist?
> > OnLoad="loadDefault(Container.DataItem("dropValue"))"
Just set the selected index in the code behind: myDropDown.SelectedIndex =
intSelectedIndex

--
S. Justin Gengo, MCP
Web Developer / Programmer

Free Code Library At:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"Robin Bonin" <robin@.guavatools.com> wrote in message
news:foidna-hLOZ1JIiiXTWJjg@.eatel.net...
> I know the value of the selectedIndex, and that is what I'm trying to
> select.
>
> "Cristian Suazo" <crillus7@.hotmail.com> wrote in message
> news:O$93Kq9SDHA.1724@.TK2MSFTNGP10.phx.gbl...
> > Are you trying to put a selected index?
> > "Robin Bonin" <robin@.guavatools.com> wrote in message
> > news:Sr6dnWpfNfAlKIiiXTWJiA@.eatel.net...
> > > I have a data grid with multiple rows. Each row has a drop down box. I
> > need
> > > it to select the correct item for each row. What I am trying to figure
> > out,
> > > is can I pass a value to the onLoad event for the dropdownlist?
> > > > OnLoad="loadDefault(Container.DataItem("dropValue"))"
> >