This is a migrated thread and some comments may be shown as answers.

Dropdown is not binding a value at update form ?

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Madhu Palakurthi
Top achievements
Rank 1
Madhu Palakurthi asked on 13 Dec 2012, 02:53 PM
Hi,
 
I have opened update form after save then dropdown selected value is not showing in the UI.
 
    <telerik:RadGrid ID="AttachmentGrid" GridLines="None" runat="server" AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True" AllowAutomaticUpdates="False" AllowPaging="True"
        DataSourceID="AttachmentDataSource" Skin="Metro" AllowSorting="True" AutoGenerateDeleteColumn="False"
        OnItemCommand="AttachmentGrid_ItemCommand">
         
        <MasterTableView Width="100%" DataKeyNames="id" DataSourceID="AttachmentDataSource"
            HorizontalAlign="NotSet" AutoGenerateColumns="False" EditMode="PopUp">
             
            <telerik:GridTemplateColumn UniqueName="InitiatorName" Groupable="False" HeaderText="Which entity or company did you receive this file from?"
                DataField="InitiatorName" Visible="false">
                <headerstyle width="1000px" />
                <itemtemplate>
                    <%#DataBinder.Eval(Container.DataItem, "InitiatorName")%>
                    </itemtemplate>
                <edititemtemplate>
                 
                        <asp:DropDownList ID="InitiatorName" runat="server" CssClass="textbox" SelectedValue='<%# Bind("InitiatorName") %>'
                                          DataSourceID="CompanyNameDataSource" DataTextField="InitiatorName" Width="300px"
                                          DataValueField="InitiatorName" OnSelectedIndexChanged="InitiatorName_SelectedIndexChanged"
                                          AutoPostBack="true">
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="ReqInitiatorName" runat="server" ControlToValidate="InitiatorName"
                                                    ErrorMessage="Please Select a Company Name" Display="Dynamic" SetFocusOnError="true" />
                    </edititemtemplate>
                     
                <asp:SqlDataSource ID="CompanyNameDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:TaskManagementConnectionString %>"
                    SelectCommand="select distinct InitiatorName from t_TaskMaster where (InitiatorName<>'' and InitiatorName is not null )union all select '' order by InitiatorName asc">
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="AttachmentDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:TaskManagementConnectionString %>"
                    SelectCommand="SELECT id,refid,[filename],[Description],[Content],upper(Status) as [Status],DateUpdated,UpdatedBy, isnull(FileCategory,'') as FileCategory ,isnull(FileMainCategory,'') as FileMainCategory,isnull([MainClassofInsurance],'') as [MainClassofInsurance],isnull([InitiatorName],'') as [InitiatorName],emailrefid FROM [t_Attachments] WHERE (FileCategory is null  or FileCategory='') and  (([UpdatedBy] = @UpdatedBy)) AND [Status] <>'DELETED' and refid<>'0'"
                    DeleteCommand="delete from t_Attachments where id=@id ">
                    <SelectParameters>
                        <asp:SessionParameter Name="UpdatedBy" SessionField="UserName" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
 
 
PLease help me on this why it's not showing selected value even SelectedValue='<%# Bind("InitiatorName") %>' is there ?

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 18 Dec 2012, 11:39 AM
Hello Narsa,

Please verify that your datasource is declared outside RadGrid and the field name is typed correctly. You could check out various demos to see practical implementation of the the requested functionality:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx

I hope this will prove helpful.

All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Madhu Palakurthi
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or