QueryString not returning anything

L

Landes

Hiya,

I have the following code in a C# aspx page, but I keep getting the
error that 'ExceptionCategoryId_' not found. Looks like the
QueryString is not returning anything.

<asp:DataGrid id=DataGrid1 runat="server"
AutoGenerateColumns="False" DataSource ="<%#
Pfc.PfcCentreExceptions.Current.DataSet %>" DataMember
='ExceptionCategoryId_<%=Request.QueryString["Category"]%>'
AllowSorting="True" PageSize="5" bordercolor="White"
BORDERWIDTH="1px" GRIDLINES="Horizontal" CELLPADDING="0"
Width="630px">

Using this code to test, the value is displayed correctly on the same
page.
<script language="javascript">
alert('<%=Request.QueryString["Category"]%>');
</script>

Can anyone point me to some clues on where I have gone wrong? I'm
obviously missing something here which i can't figure out. :( Anyone
with any idea to help will be greatly appreciated, thanks!
 
G

Guest

Hi Landes,


<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataGrid1.DataSource = Pfc.PfcCentreExceptions.Current.DataSet;
DataGrid1.DataBind();
}
}
</script>

<asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="False"
DataMember='<%# "ExceptionCategoryId_" + Request.QueryString["Category"] %>'
AllowSorting="True" PageSize="5" BorderColor="White" BorderWidth="1px"
GridLines="Horizontal" CellPadding="0"
Width="630px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
a
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
 
G

Guest

Example:

//Codebehind:
protected string test = "";
private void Page_Load(object sender, System.EventArgs e)
{
if(Request.QueryString["test"]!=null)
test = Request.QueryString["test"];

//Page (ASPX):
<script>
var test ='<%=test %>'
alert( test);
</script>

Peter
 
E

Eliyahu Goldin

<%= is a shortcut for Response.Write(). In other words, it sends the
evaluated value to the client response stream. Using it in a pure
server-side definition, like DataMember, has no meaning. DataMember is
intented for things like table names. What are you trying to set it to?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top