Template HyperLink NavigateUrl value in DataGrid?

shahab

Junior Contributor
Joined
Aug 14, 2003
Messages
206
Location
Iran(Middle East)
Dear guys,
I have many Templated hyperlinks in a DataGrid,which when ever I click on one of them a QueryString like this is created :
Code:
NavigateUrl='<%# "NewsDetails.aspx?NewsId="+DataBinder.Eval(Container, "DataItem.NewsId") %>' Text='<%# DataBinder.Eval(Container, "DataItem.subject") %>'>

Now I need to access to NewsId,subject value(String Value) in code behind:
I use this code :
Code:
private void Button1_Click(object sender, System.EventArgs e)
		{
			// Create the queryString object
			SecureQueryString qs = new SecureQueryString();
			// Add name/value pairs.
			//qs["NewsId"] = "a"; this works well
			//qs["NewsId"] = (HyperLink)e.Item.FindControl("HyperLink1").ID.ToString();
			//DataBinder.Eval(Container, "DataItem.NewsId");
			string HyperlinkNavigateUrl = DataBinder.Eval(Container, "DataItem.NewsId");
			string HyperlinkText = DataBinder.Eval(Container, "DataItem.Subject");
			
			// Redirect to the Destination page.   We simply call the ToString() method of 
			// SecureQuerySting to pass the encrypted data.
			Response.Redirect("NewsDetails.aspx?NewsId=" + qs.ToString());	
		}

Error:
Code:
 'System.ComponentModel.Container' denotes a 'class' where a 'variable' was expected
How can I get these values in Code Behond?
 
My Goal is To encrypting the string values in QueryStrings,and I do not like to put my code between html tags(That everyone can access to them!!!!).
Is that clear dear Zeidan?
 
I think theres a way to do that.

Declare a function in your codebehind file that encrypts the values, and use it in your aspx file, like this

NavigateUrl='<%# "NewsDetails.aspx?NewsId="+enc(DataBinder.Eval(Container, "DataItem.NewsId")) %>' Text='<%# DataBinder.Eval(Container, "DataItem.subject") %>'>

enc(), is your function.......get what I mean
 
Back
Top