kw66722
asked on
adding DropDownList to gridview selectvalue is bound to source field
I am try to add a DropDownList to a gridview where the selected value of the dropdownlist is from one of the bound fields.
I tried the below code and that shows both fields. I only want the dropdownlist.
<asp:BoundField DataField="sample_type_id" HeaderText="Sample Type"
SortExpression="sample_typ e_id" HeaderStyle-Font-Names="ve rdana, arial, helvetica;" HeaderStyle-Font-Size="9px " />
<asp:templatefield headertext="Sample Type" HeaderStyle-Font-Names="ve rdana, arial, helvetica;" HeaderStyle-Font-Size="9px ">
<itemtemplate>
<asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="sampleTypeIn fo"
DataTextField="sampleTypeI nfo" DataValueField="sampleType _id">
</asp:DropDownList>
</itemtemplate>
</asp:templatefield>
I tried the below code and that shows both fields. I only want the dropdownlist.
<asp:BoundField DataField="sample_type_id"
SortExpression="sample_typ
<asp:templatefield headertext="Sample Type" HeaderStyle-Font-Names="ve
<itemtemplate>
<asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="sampleTypeIn
DataTextField="sampleTypeI
</asp:DropDownList>
</itemtemplate>
</asp:templatefield>
ASKER
From that sample I am not sure how to change the selected value to the value of the bound field.
I want the DropDownList4.selectValue = boundfield sample_type_id value
How would I get the value of the boundfield and then set the dropdownlist field.
I want the DropDownList4.selectValue = boundfield sample_type_id value
How would I get the value of the boundfield and then set the dropdownlist field.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.codeproject.com/KB/webforms/DropdownInsideGridview.aspx