Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0GridView CommandField Select doesnGridView CommandField Select doesn't work correct in DotNetNuke ?
Previous
 
Next
New Post
7/17/2007 10:28 PM
 

I'm building a Customer Management Module. I have  Customer table with 12 columns: CustomerID, ModuleID, FullName, Password, Birthday, Email, Tel, Mobile, Address, City, Country, Description. I create one user control to view and edit customer information include a GridView list customers and a FormView to show detail information.

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    AutoGenerateColumns="False" DataKeyNames="CustomerID"
    DataSourceID="SqlDataSource1" EnableViewState="False" Width="100%">
    <Columns>       
        <asp:TemplateField HeaderText="No.">
            <ItemTemplate>
                <asp:Label ID="OrdinalCustomer" runat="server"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:CommandField ShowSelectButton="True" Visible="False" />
        <asp:CommandField ShowDeleteButton="True" />
        <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" SortExpression="CustomerID" Visible="False" />
        <asp:BoundField DataField="ModuleID" HeaderText="ModuleID" SortExpression="ModuleID" Visible="False" />
        <asp:BoundField DataField="FullName" HeaderText="FullName" SortExpression="FullName" />       
        <asp:BoundField DataField="Birthday" HeaderText="Birthday" SortExpression="Birthday" DataFormatString="{0:dd-MM-yyyy}" HtmlEncode="False"/>
        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
        <asp:BoundField DataField="Tel" HeaderText="Tel" SortExpression="Tel" />
        <asp:BoundField DataField="Mobile" HeaderText="Mobile" SortExpression="Mobile" />
        <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
        <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />       
        <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country" />
    </Columns>
    <EmptyDataTemplate>
        There are no Customer Records
    </EmptyDataTemplate>
    <AlternatingRowStyle CssClass="AlternatingRowStyle" />
    <RowStyle CssClass="RowStyle" />
    <HeaderStyle CssClass="HeaderStyle" />   
    <SelectedRowStyle CssClass="SelectedRowStyle" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dotnetnukeConnectionString %>" SelectCommand="SELECT [CustomerID], [ModuleID], [FullName], [Birthday], [Email], [Tel], [Mobile], [Address], [City], [Country] FROM [Customer]" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [Customer] WHERE [CustomerID] = @original_CustomerID AND [ModuleID] = @original_ModuleID AND [FullName] = @original_FullName AND [Birthday] = @original_Birthday AND [Email] = @original_Email AND [Tel] = @original_Tel AND [Mobile] = @original_Mobile AND [Address] = @original_Address AND [City] = @original_City AND [Country] = @original_Country" InsertCommand="INSERT INTO [Customer] ([CustomerID], [ModuleID], [FullName], [Birthday], [Email], [Tel], [Mobile], [Address], [City], [Country]) VALUES (@CustomerID, @ModuleID, @FullName, @Birthday, @Email, @Tel, @Mobile, @Address, @City, @Country)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [Customer] SET [ModuleID] = @ModuleID, [FullName] = @FullName, [Birthday] = @Birthday, [Email] = @Email, [Tel] = @Tel, [Mobile] = @Mobile, [Address] = @Address, [City] = @City, [Country] = @Country WHERE [CustomerID] = @original_CustomerID AND [ModuleID] = @original_ModuleID AND [FullName] = @original_FullName AND [Birthday] = @original_Birthday AND [Email] = @original_Email AND [Tel] = @original_Tel AND [Mobile] = @original_Mobile AND [Address] = @original_Address AND [City] = @original_City AND [Country] = @original_Country">
    <DeleteParameters>
        <asp:Parameter Name="original_CustomerID" Type="Int32" />
        <asp:Parameter Name="original_ModuleID" Type="Int32" />
        <asp:Parameter Name="original_FullName" Type="String" />
        <asp:Parameter Name="original_Birthday" Type="DateTime" />
        <asp:Parameter Name="original_Email" Type="String" />
        <asp:Parameter Name="original_Tel" Type="String" />
        <asp:Parameter Name="original_Mobile" Type="String" />
        <asp:Parameter Name="original_Address" Type="String" />
        <asp:Parameter Name="original_City" Type="String" />
        <asp:Parameter Name="original_Country" Type="String" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="ModuleID" Type="Int32" />
        <asp:Parameter Name="FullName" Type="String" />
        <asp:Parameter Name="Birthday" Type="DateTime" />
        <asp:Parameter Name="Email" Type="String" />
        <asp:Parameter Name="Tel" Type="String" />
        <asp:Parameter Name="Mobile" Type="String" />
        <asp:Parameter Name="Address" Type="String" />
        <asp:Parameter Name="City" Type="String" />
        <asp:Parameter Name="Country" Type="String" />
        <asp:Parameter Name="original_CustomerID" Type="Int32" />
        <asp:Parameter Name="original_ModuleID" Type="Int32" />
        <asp:Parameter Name="original_FullName" Type="String" />
        <asp:Parameter Name="original_Birthday" Type="DateTime" />
        <asp:Parameter Name="original_Email" Type="String" />
        <asp:Parameter Name="original_Tel" Type="String" />
        <asp:Parameter Name="original_Mobile" Type="String" />
        <asp:Parameter Name="original_Address" Type="String" />
        <asp:Parameter Name="original_City" Type="String" />
        <asp:Parameter Name="original_Country" Type="String" />
    </UpdateParameters>
    <InsertParameters>
        <asp:Parameter Name="CustomerID" Type="Int32" />
        <asp:Parameter Name="ModuleID" Type="Int32" />
        <asp:Parameter Name="FullName" Type="String" />
        <asp:Parameter Name="Birthday" Type="DateTime" />
        <asp:Parameter Name="Email" Type="String" />
        <asp:Parameter Name="Tel" Type="String" />
        <asp:Parameter Name="Mobile" Type="String" />
        <asp:Parameter Name="Address" Type="String" />
        <asp:Parameter Name="City" Type="String" />
        <asp:Parameter Name="Country" Type="String" />
    </InsertParameters>
</asp:SqlDataSource>
<br />
<fieldset>
<legend>
Customer Information
</legend>
<asp:FormView ID="FormView1" runat="server" CssClass="DetailView" DataKeyNames="CustomerID"
    DataSourceID="SqlDataSource2" DefaultMode="Insert" Width="100%" >   
    <EditItemTemplate>
        <table border="0" cellpadding="0" cellspacing="1" class="DetailView" style="azimuth: center"
            width="100%">
            <tr>
                <td align="right" style="width: 30%;height:10">
                </td>
                <td style="padding-left: 20px">
                </td>
            </tr>
            <tr>
                <td align="right" colspan="2">
                    <asp:TextBox ID="ModuleID" runat="server" Text='<%# Bind("ModuleID") %>' Visible="False"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblFullName" runat="server" Text="FullName:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="FullName" runat="server" EnableViewState="False" Text='<%# Bind("FullName") %>'
                        Width="70%"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblPassword" runat="server" Text="Password:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="Password" runat="server" EnableViewState="False" Text='<%# Bind("Password") %>'></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblBirthday" runat="server" Text="Birthday:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="Birthday" runat="server" EnableViewState="False" Text='<%# Bind("Birthday") %>'></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblEmail" runat="server" Text="Email:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="Email" runat="server" EnableViewState="False" Text='<%# Bind("Email") %>'></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblTel" runat="server" Text="Tel:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="Tel" runat="server" EnableViewState="False" Text='<%# Bind("Tel") %>'></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblMobile" runat="server" Text="Mobile:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="Mobile" runat="server" EnableViewState="False" Text='<%# Bind("Mobile") %>'></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblAddress" runat="server" Text="Address:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="Address" runat="server" EnableViewState="False" Text='<%# Bind("Address") %>'
                        Width="70%"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblCity" runat="server" Text="City:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:DropDownList ID="cboCity" runat="server">                     
                    </asp:DropDownList>               
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblZipCode" runat="server" Text="ZipCode:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="ZipCode" runat="server" EnableViewState="False" Text='<%# Bind("ZipCode") %>'
                        ></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblCountry" runat="server" Text="Country:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:DropDownList ID="cboCountry" runat="server">                     
                        <asp:ListItem>South Korea</asp:ListItem>
                        <asp:ListItem>USA</asp:ListItem>
                        <asp:ListItem>China</asp:ListItem>
                        <asp:ListItem>Thailand</asp:ListItem>
                        <asp:ListItem>Russia</asp:ListItem>
                    </asp:DropDownList>               
                </td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Label ID="lblDescription" runat="server" Text="Description:"></asp:Label>
                </td>
                <td style="padding-left: 20px">
                    <asp:TextBox ID="Description" runat="server" EnableViewState="False" Rows="4" Text='<%# Bind("Description") %>'
                        TextMode="MultiLine" Width="70%"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="height:10"></td>
            </tr>          
            <tr>
                <td align="right">                   
                </td>
                <td style="padding-left: 20px">
                    <asp:LinkButton ID="UpdateItemButton" runat="server" CausesValidation="True" CommandName="Update"
                        OnClick="UpdateItemButton_Click" Text="Update">
                    </asp:LinkButton>&nbsp;
                    <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                        OnClick="UpdateCancelButton_Click" Text="Cancel">
                    </asp:LinkButton>
                </td>
            </tr>
        </table>
    </EditItemTemplate>
</asp:FormView>
<br />
</fieldset>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:dotnetnukeConnectionString %>"
    SelectCommand="SELECT * FROM [Customer] WHERE ([CustomerID] = @CustomerID)">
    <SelectParameters>
        <asp:ControlParameter ControlID="GridView1" Name="CustomerID" PropertyName="SelectedValue"
            Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>

It's OK but when I select row on GridView, the details not display on FormView (sometimes it works) unless I login as admin or host user and page mode is Edit ( if the page mode is View, the problem is the same).
It made me crazy. Thanks for any solutions

 
New Post
7/17/2007 11:22 PM
 

It's probably the module caching, set it to 0. see: Answers to Common Module Development Errors



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0GridView CommandField Select doesnGridView CommandField Select doesn't work correct in DotNetNuke ?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out