Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'System.Web.HttpRequest.QueryString' denotes a 'property' where a 'met

Status
Not open for further replies.

devondago

Programmer
Jan 22, 2003
38
0
0
US
I have create a datalist that displays book titles as hyperlinks once the hiperlink is clicked it then takes you to an edit page. the hyperlink looks like this.
<asp:hyperlink id="link" Runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Title" )%>' NavigateURL='<%# Request.ApplicationPath + "/edit.aspx?id=" + DataBinder.Eval(Container.DataItem, "ref_id" ) %>'/>
my problem is as follow when i get to the edit page. instead of displaying one record at a time it displays all records one after the other one on my datalist. I have tried to use the following query to select the data and only display one record at a time on the edit page.
cmdSelect = new SqlCommand( "Select book_id, title, passage, date, location where book_id =' " + Request.("ID") +" ' Order by passage", cn );
I am getting an error System.Web.UI.Page.Reuqest' denotes a 'property' where a 'method; was expected.
Can anyone help solve this issue.all help will be appreciated to get passed this error.
 
Unlike VB, collections in c# are referenced using square brackets rather than round brackets. Hence the error where a method is expected as these are denoted by round brackets. Try

Request.Querystring["ID"]

Rob

Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
thanks for the tip....getting this error now...
Invalid column name 'ref_id'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'ref_id'.

Source Error:


Line 64: cmdSelect = new SqlCommand( "Select book_id, title, passage, date, location where book_id = '" + Request.QueryString["ID"] + "' order by title", cn );
Line 65:
Line 66: dtrRelease = cmdSelect.ExecuteReader();
Line 67:
Line 68: dlstRelease.DataSource = dtrRelease;


Source File: c:\inetpub\ Line: 66

Stack Trace:


[SqlException: Invalid column name 'ref_id'.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
System.Data.SqlClient.SqlCommand.ExecuteReader()
AdminApplication.edit.BindDataList() in c:\inetpub\ AdminApplication.edit.Page_Load(Object sender, EventArgs e) in c:\inetpub\ System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()
 
Try this...
Request.QueryString["ID"].ToString();
if that doesn't cut it, check the value of "ID", make sure it's a good one.

good luck
 
same error
Invalid column name 'book_id'.

Line 64: cmdSelect = new SqlCommand( "Select book_id, title, passage, date, location where book_id = '" + Request.QueryString["ID"].ToString() + "' order by title", cn );
Line 65:
Line 66: dtrRelease = cmdSelect.ExecuteReader();
Line 67:
Line 68: dlstRelease.DataSource = dtrRelease;

here is my code on my datalist. maybe someone can help me point out what i need.
void BindDataList()
{
SqlCommand cmdSelect;
SqlDataReader dtrRelease;
SqlConnection con = new SqlConnection();
con.ConnectionString = TEST.ConnectString.mytestdrive();
con.Open();
cmdSelect = new SqlCommand( "Select book_id, title, passage, date, location where book_id = '" + Request.QueryString["ID"].ToString() + "' order by title", con );

dtrRelease = cmdSelect.ExecuteReader();

dlstRelease.DataSource = dtrRelease;
dlstRelease.DataBind();
dtrRelease.Close();
con.Close();

}
thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top