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

Verify Data from stored proc in a drop down

4 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 08 Feb 2011, 05:32 AM

I would appreciate it if someone could point me in the right direction to solve my issue.

I have a radgrid that has returns all the media such as audio, video and other media etc associated with it that particular message. Then on edit I have a dropdown whose data source populates the dropdown with all the possible audio files. Now on edit if there was a audio file chosen, it will be displayed in the dropdown and the selected value is a guid.

My issue is that IF the audiofile gets deleted before it is removed from the message, it breaks. I want to verify that the audio file still exists. Hope it all makes sense.

 

<

 

telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid1" DataSourceID="SqlDataSource1"

 

 

 

 

 

AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" runat="server"

 

 

 

 

 

Skin="Telerik" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" PageSize="10"

 

 

 

 

 

AllowAutomaticUpdates="True" OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted"

 

 

 

 

 

OnItemInserted="RadGrid1_ItemInserted" ShowStatusBar="true" Width="600px" OnItemCommand="RadGrid1_ItemCommand">

 

 

 

 

 

<PagerStyle Mode="NextPrevAndNumeric" />

 

 

 

 

 

<GroupingSettings CaseSensitive="false" />

 

 

 

 

 

<MasterTableView TableLayout="Fixed" DataKeyNames="episodeGuid" CommandItemDisplay="TopAndBottom">

 

 

 

 

 

<Columns>

 

 

 

 

 

<telerik:GridEditCommandColumn HeaderStyle-Width="40px" FilterControlWidth="30px"

 

 

 

 

 

ButtonType="ImageButton" UniqueName="EditCommandColumn">

 

 

 

 

 

<ItemStyle CssClass="MyImageButton" />

 

 

 

 

 

</telerik:GridEditCommandColumn>

 

 

 

 

 

<telerik:GridBoundColumn SortExpression="messageGuid" HeaderText="messageGuid" DataField="messageGuid"

 

 

 

 

 

UniqueName="messageGuid" Visible="false" ReadOnly="true">

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridBoundColumn SortExpression="episodeTitle" HeaderText="title" DataField="episodeTitle">

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridBoundColumn SortExpression="date" HeaderText="date" DataField="date">

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

<telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"

 

 

 

 

 

ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"

 

 

 

 

 

UniqueName="DeleteColumn">

 

 

 

 

 

<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />

 

 

 

 

 

</telerik:GridButtonColumn>

 

 

 

 

 

</Columns>

 

 

 

 

 

<EditFormSettings ColumnNumber="1" CaptionDataField="Epsiode" CaptionFormatString="Edit properties ministry {0}"EditFormType="Template">

 

 

 

 

 

<FormTemplate><table cellpadding="5" cellspacing="0" border="0"><

 

tr><td class="formFieldNameGeneric">Episode Video File</td><td class="formField"><asp:DropDownList ID="dlVideos" runat="server" DataTextField="videoTitle" DataValueField="videoGuid"SelectedValue='<%# Bind( "videoGuid") %>' AppendDataBoundItems="true" CssClass="DropDown"DataSourceID="SqlDataSource2"><asp:ListItem Text="None" Value=""></asp:ListItem></asp:DropDownList></td></tr>

I was thinking something along these lines but I could never get it to work

 

protected

 

void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)

 

{


GridEditCommandColumn

 

editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn");

 


try

{

//If the file exists then bind it to the dropdown

}

 

 

catch

 

{

//The file was deleted. Selected value is now NULL.

}


}

Thanks for the help!!!

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Feb 2011, 08:54 AM
Hello Mike,

I hope the issue is when deleting a row in grid, it causes deletion form dropdownlist. I have not experienced such issue. Please check the stored procedure and make sure you have bind the DropDownList correctly. Here is demo showing how to use dropdownlist in formtemplate with certain options.
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx

Thanks,
Princy.
0
Mike
Top achievements
Rank 1
answered on 08 Feb 2011, 04:30 PM
Hi Princy,
No, that's not the issue I am having. I have a separate tool (audio upload) where it allows a user to add/remove etc audio files.
Then in the tool I am having issues with (media center) you can pick the audio file that was uploaded in the above tool.

My issues is that the user uploaded an audio file in the audio library then attached it via the media center.After some time they went and deleted the file from the audio library causing the message center to fail as it is still looking for the file.

messagecenter radgrid datasource pulls in all messages. Then I have a dropdown whose datasource shows all available audio files. Now when a user deletes from the audio library, it fails because the message center tool is still returning it. I need to update my procs to delete it from the message center as well but first I want to put in error catch.

Hope that sheds more light
Thanks!

0
Mike
Top achievements
Rank 1
answered on 09 Feb 2011, 08:36 PM
I would like to add to this using the example princy sent.

Let's say I have a tool that allows me to update the title of courtesy dropdown. We'll call it the TC Tool
Title Of Courtesy


Lets say in TC Tool I don't want to list the "Ms." field any longer and I delete it. NOW in the example from Princy "Janet Leverling uses that value but since I deleted it from teh TC Tool it can no longer bind. I need to error capture if MS. is deleted from the TC Tool and have it go to a default selected dropdown like. Choose One....

As of right now everything is working great except for when I run into the issue above. I can add, delete, update without issue unless my value was deleted from the other tool I built.
0
sasho
Top achievements
Rank 1
answered on 09 Feb 2011, 09:41 PM
Under ItemDataBound for the grid_ItemDataBound

If the Item=List
select all values for the dropdown from Dropdownvalueslist
Droplist.Datasource = DropDownvalues;
Droplist.Datatextfield = dropdownvalues.Name;
droplist.datavaluefield = dropdownvalues.values
droplist.databind();

In your HTML remove the Bind part for your dropdown list. and bind via codebehind.

If a record is removed after the page is loaded you have a dataconcurrency issue to work out.
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mike
Top achievements
Rank 1
sasho
Top achievements
Rank 1
Share this question
or