Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.NET dropdownlist/gridview databinding using SqlDataSource

Posted on 2010-11-11
8
Medium Priority
?
732 Views
Last Modified: 2012-05-10
Hi,

I have to databind gridview with sproc resultset that has parameters from two DropDownLists. First  parameter should be equal the value of DataTextField and second should be equal the value of DataValueField . What should be written instead of ‘?????’ .

<asp:SqlDataSource  .....  >
  <SelectParameters>
    <asp:ControlParameter ControlID="DropDownList1" PropertyName="?????"  ... />
    <asp:ControlParameter ControlID="DropDownList2" PropertyName="?????"  ... />
  </SelectParameters>
</asp:SqlDataSource>


Thanks.
0
Comment
Question by:quasar_ee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 1000 total points
ID: 34114569
Try Text and SelectedValue properties
0
 
LVL 6

Expert Comment

by:AliSyed
ID: 34114790
<asp:ControlParameter ControlID="DropDownList1" PropertyName="SelectedValue" />
    <asp:ControlParameter ControlID="DropDownList2" PropertyName="Text"/>
0
 
LVL 7

Assisted Solution

by:mr_nadger
mr_nadger earned 1000 total points
ID: 34119883
example attached for you
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="dummy._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        text
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
            <asp:ListItem>Monday</asp:ListItem>
            <asp:ListItem>Tuesday</asp:ListItem>
            <asp:ListItem>Wednesday</asp:ListItem>
            <asp:ListItem>Thursday</asp:ListItem>
            <asp:ListItem>Friday</asp:ListItem>
            <asp:ListItem>Saturday</asp:ListItem>
            <asp:ListItem>Sunday</asp:ListItem>
        </asp:DropDownList>
        <br />
        <br />
        value         
        <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True">
            <asp:ListItem Value="1">High</asp:ListItem>
            <asp:ListItem Value="2">Low</asp:ListItem>
        </asp:DropDownList>
        
    
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ServiceBridgeV3ConnectionString %>" 
        SelectCommand="p_test" SelectCommandType="StoredProcedure">
        <SelectParameters>
            <asp:ControlParameter ControlID="DropDownList1" Name="day" 
                PropertyName="Text" Type="String" />
            <asp:ControlParameter ControlID="DropDownList2" Name="sev" 
                PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="intID" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="intID" HeaderText="intID" InsertVisible="False" 
                ReadOnly="True" SortExpression="intID" />
            <asp:BoundField DataField="HPOVID" HeaderText="HPOVID" 
                SortExpression="HPOVID" />
        </Columns>
    </asp:GridView>
    </form>
</body>
</html>

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:AliSyed
ID: 34124810
Gurusami already gave the same  answer i gave. Please do not accept my answer as solution.
0
 

Author Comment

by:quasar_ee
ID: 34311852
ok
0
 

Author Comment

by:quasar_ee
ID: 34311856
ok
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34317306
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question