Not sure what I am missing:
I have a radcombobox - "box1" It is populated from a dataset. my page_load sub looks to to see if Request.querystring("terr") contains data. If it does I want to look at my combobox items and see if one of the items value is the same as the the querystring. if so, I want to change to the selection to that item.
my code:
I added a label to try and figure out what is going on, and it appears that my code for looking through the items in box1 is in correct as no item values are being appended to my label.
ASPX code:
I have a radcombobox - "box1" It is populated from a dataset. my page_load sub looks to to see if Request.querystring("terr") contains data. If it does I want to look at my combobox items and see if one of the items value is the same as the the querystring. if so, I want to change to the selection to that item.
my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load | |
If Not Page.IsPostBack Then | |
box1.SelectedIndex = 0 | |
If Not Request.QueryString("terr") Is Nothing Then | |
Dim myterr As String | |
myterr = Server.UrlDecode(Request.QueryString("terr")) | |
For Each item As RadComboBoxItem In box1.Items | |
myterr = myterr & " - " & item.Value | |
If Trim(item.Value) = Trim(myterr) Then | |
item.Selected = True | |
End If | |
Next | |
Label2.Text = myterr | |
' box1.SelectedValue = Request.QueryString("terr") | |
Else | |
Label2.Text = " " | |
End If | |
End If |
I added a label to try and figure out what is going on, and it appears that my code for looking through the items in box1 is in correct as no item values are being appended to my label.
ASPX code:
<%@ Page Language="VB" MasterPageFile="~/SalesTools.master" AutoEventWireup="false" CodeFile="prospects.aspx.vb" Inherits="prospects" title="Prospects" %> | |
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> | |
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> | |
<telerik:RadComboBox ID="RadioButtonList1" runat="server" AutoPostBack="True" | |
DataSourceID="SqlDataSource2" DataTextField="CODETERR" DataValueField="CODETERR" | |
RepeatDirection="Horizontal" Skin="Hay" > | |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> | |
</telerik:RadComboBox > | |
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> | |
| |
<asp:GridView ID="gvProspects" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID" | |
DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" EnableTheming="True" GridLines="Horizontal" SkinID="prospectgrid"> | |
<Columns> | |
<asp:TemplateField InsertVisible="False" ShowHeader="False"> | |
<EditItemTemplate> | |
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" | |
Text="Update"></asp:LinkButton> | |
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" | |
Text="Cancel"></asp:LinkButton> | |
</EditItemTemplate> | |
<ItemTemplate> | |
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" | |
Text="Edit"></asp:LinkButton> | |
</ItemTemplate> | |
</asp:TemplateField> | |
<asp:BoundField DataField="CustomerID" HeaderText="CustomerID" InsertVisible="False" | |
ReadOnly="True" SortExpression="CustomerID" /> | |
<asp:TemplateField HeaderText="NameCust" SortExpression="NameCust"> | |
<EditItemTemplate> | |
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("NameCust") %>'></asp:TextBox> | |
</EditItemTemplate> | |
<ItemTemplate> | |
<asp:Label ID="Label1" runat="server" Text='<%# Bind("NameCust") %>'></asp:Label> | |
</ItemTemplate> | |
</asp:TemplateField> | |
</Columns> | |
<FooterStyle BackColor="White" ForeColor="#333333" /> | |
<RowStyle BackColor="White" ForeColor="#333333" /> | |
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" /> | |
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" /> | |
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" /> | |
</asp:GridView> | |
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="548px"> | |
<asp:Button ID="Button1" runat="server" Text="New Prospect" ValidationGroup="insertCust" /> | |
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox2" | |
ErrorMessage="Prospect Name can not be blank" ValidationGroup="insertCust"></asp:RequiredFieldValidator> | |
<asp:TextBox ID="TextBox2" runat="server" Width="330px" ValidationGroup="insertCust"></asp:TextBox></asp:Panel> | |
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:AccPac2ConnectionString %>" | |
SelectCommand="Select ter.CODETERR from ((SELECT DISTINCT CODETERR FROM dbo.F_arcus() AS F_arcus_1 WHERE (DATELASTIV > dbo.Accpacdate(DATEADD(yyyy, - 1, GETDATE()))) AND (CODETERR <> '')) union (select 'IH')) ter"> | |
</asp:SqlDataSource> | |
<telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server" Skin="Web20" /> | |
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AccPac2ConnectionString %>" | |
InsertCommand="INSERT INTO dbo.BudgetProspects(NameCust, CodeTerr) VALUES (@Namecust, @codeterr)" | |
SelectCommand="SELECT CustomerID, NameCust FROM dbo.BudgetProspects WHERE (CodeTerr = @codeterr)" | |
UpdateCommand="UPDATE dbo.BudgetProspects SET NameCust = @namecust where customerID = @customerid"> | |
<UpdateParameters> | |
<asp:Parameter Name="namecust" /> | |
<asp:Parameter Name="customerid" /> | |
</UpdateParameters> | |
<SelectParameters> | |
<asp:ControlParameter ControlID="RadioButtonList1" Name="codeterr" PropertyName="SelectedValue" /> | |
</SelectParameters> | |
<InsertParameters> | |
<asp:ControlParameter ControlID="textbox2" Name="Namecust" PropertyName="text" /> | |
<asp:ControlParameter ControlID="RadioButtonList1" Name="codeterr" PropertyName="SelectedValue" /> | |
</InsertParameters> | |
</asp:SqlDataSource> | |
</asp:Content> |