Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

HELP! ASP.NET Datagrid problem.

Posted 01 Apr 2004 11:41:23
1
has voted
01 Apr 2004 11:41:23 Ibnu Haris posted:
I'm a newbie is ASP.net, I'm using DWMX for the development. I'm doing a query and I want it displayed on a datagrid. The query is fine, I've tested it in SQL Query Analyzer. When I put into the query my variables it returns the datagrid just fien. However, it I change the variables to URL variable(@variable), which is the input from dropdown lists and textbox, the query does not return any results in the DataGrid. Here's my code. Can anyone help? FYI, I'm doing it in DWMX.

<pre id=code><font face=courier size=2 id=code>
&lt;/head&gt;
&lt;body&gt;
&lt;form action="" method="post" name="UpdateItem" id="UpdateItem" runat="server" &gt;
&lt;p&gt;&nbsp;&lt;/p&gt;
&lt;table width="69%" border="0" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF" class="Body" id="TblnsItem"&gt;
&lt;tr bordercolor="#999999"&gt;
&lt;td class="Body"&gt;&lt;div align="right"&gt;&lt;strong&gt;Retailer Name&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt; &lt;div align="left"&gt;
&lt;asp:dropdownlist DataSource="&lt;%#RetailerName.DefaultView%&gt;" DataTextField="RetName" DataValueField="RetName" ID="RetName" Rows="1" runat="server" SelectionMode="single"&gt;&lt;/asp:dropdownlist&gt;

&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr bordercolor="#999999"&gt;
&lt;td class="Body"&gt;&lt;div align="right"&gt;&lt;strong&gt;Promo Date Start&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt; &lt;div align="left"&gt;
&lt;asp:dropdownlist DataSource="&lt;%#DateDS.DefaultView%&gt;" DataTextField="PromoDateStart" DataValueField="PromoDateStart" ID="PromoDateStart" Rows="1" runat="server" SelectionMode="single"&gt;&lt;/asp:dropdownlist&gt;

&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr bordercolor="#999999"&gt;
&lt;td width="30%" class="Body"&gt; &lt;div align="right"&gt;&lt;strong&gt;Item Brand&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td&gt; &lt;div align="left"&gt;
&lt;asp:textbox ID="ItemBrand" runat="server" TextMode="SingleLine" /&gt;

&lt;/div&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;% if Request("error" = "true" then %&gt;
&lt;% end if %&gt;

&lt;tr bordercolor="#999999"&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td width="27%"&gt; &lt;div align="right"&gt;
&lt;asp:button ID="Select" runat="server" Text="Select Item" /&gt;

&lt;/div&gt;&lt;/td&gt;
&lt;td width="21%"&gt;&nbsp; &lt;/td&gt;
&lt;td width="22%"&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;





&lt;aspataGrid
AllowCustomPaging="true"
AllowPaging="true"
AllowSorting="true"
AutoGenerateColumns="false"
CellPadding="3"
CellSpacing="0" DataKeyField="ItemID2"
DataSource="&lt;%# GetItem.DefaultView %&gt;" id="ItemGrid"
PagerStyle-Mode="NumericPages"
PageSize="&lt;%# GetItem.PageSize %&gt;"
runat="server"
ShowFooter="false"
ShowHeader="true" OnUpdateCommand="GetItem.OnDataGridUpdate" OnEditCommand="GetItem.OnDataGridEdit"
OnPageIndexChanged="GetItem.OnDataGridPageIndexChanged" OnCancelCommand="GetItem.OnDataGridCancel" OnDeleteCommand="GetItem.OnDataGridDelete" OnItemDataBound="GetItem.OnDataGridItemDataBound"
VirtualItemCount="&lt;%# GetItem.RecordCount %&gt;"
&gt;
&lt;HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" /&gt;
&lt;ItemStyle BackColor="#F2F2F2" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" /&gt;
&lt;AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" /&gt;
&lt;FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" /&gt;
&lt;PagerStyle BackColor="white" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" /&gt;
&lt;Columns&gt;
&lt;asp:EditCommandColumn
ButtonType="PushButton"
CancelText="Cancel"
EditText="Edit"
HeaderText="Edit Item"
UpdateText="Update"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="RetID2"
HeaderText="Retailer ID"
ReadOnly="true"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="RetName"
HeaderText="Retailer Name"
ReadOnly="true"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="PromoDateStart"
HeaderText="Promo Date Start"
ReadOnly="true"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="ItemID2"
HeaderText="Item ID"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="ItemBrand"
HeaderText="Item Brand"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="ItemCategory"
HeaderText="Item Category"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="ItemShortDesc"
HeaderText="Item Short Description"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="ItemLongDesc"
HeaderText="Item Long Description"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="ItemCondition"
HeaderText="Item Condition"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="ItemOffer"
HeaderText="Item Offer"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="ItemPrice"
HeaderText="Item Price"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="MydItemId"
HeaderText="Mydin Item ID"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:BoundColumn DataField="MydSupplierID"
HeaderText="Mydin Supplier ID"
ReadOnly="false"
Visible="True"/&gt;
&lt;asp:ButtonColumn
ButtonType="PushButton"
CommandName="Delete"
HeaderText="Delete Item"
Text="Delete"
Visible="True"/&gt; &lt;/Columns&gt;
&lt;/aspataGrid&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&nbsp; &lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</font id=code></pre id=code>

Edited by - alhariz on 02 Apr 2004 06:31:17

Reply to this topic