I'm modifying an old application. Because the application has changed over the years, we have two fields that we now want to effectively be the same. Once upon a time, we were using the Email field to store the login ID for the user. At some later time, we created a Username field, which is usually null.
We have an awful lot (at least a couple dozen) of stored procedures that return the Email field for the username, but only a few that update the database with information, including the login information. We can synchronize the two fields.
I want to display the Email field in my grid, and update using the Username field. Is this possible?
Here is the relevant code:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True" Width="97%" OnItemCommand="RadGrid1_ItemCommand"
AllowSorting="True" DataSourceID="SQLDataSource1" ShowStatusBar="True" PageSize="15"
Skin="Telerik" AllowAutomaticUpdates="True" AutoGenerateColumns="False" AutoGenerateEditColumn="True" AutoGenerateDeleteColumn="True">
<PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
<MasterTableView DataKeyNames="UserID" DataSourceID="SQLDataSource1" AllowAutomaticDeletes="True" CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand">
<CommandItemSettings ShowExportToWordButton="true" ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false"></CommandItemSettings>
<Columns>
<telerik:GridBoundColumn DataField="Email" FilterControlAltText="Filter Login column" HeaderText="Login" SortExpression="Username" UniqueName="Username" FilterControlWidth="70px">
</telerik:GridBoundColumn>
<asp:SqlDataSource ConnectionString="<%$ ConnectionStrings:TasksConnectionString %>" ID="SQLDataSource1"
runat="server" SelectCommand="GetScannerUsers" SelectCommandType="StoredProcedure" UpdateCommand="UpdateScannerUsers" UpdateCommandType="StoredProcedure" InsertCommand="AddScannerUsers" InsertCommandType="StoredProcedure" DeleteCommand="DeleteUser" DeleteCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="UserID" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Username" Type="String" />
</UpdateParameters>
Note that I have tried to use the DataField and UniqueName properties to try to display data for Email yet access the Username field for updates. This isn't working, as I find the UpdateScannerUsers stored procedure is receiving NULL for the Username parameter value. I also find it's adding the Email parameter to the end of the stored procedure call.
Not relevant to the current problem, but we eventually use the Email field in the future to actually store an email address. It was probably storing the user ID because both email and username ought to be unique within the database.