Click here to Skip to main content
15,916,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I'm confused of using datalist or gridview in my users managing page
the managing is about : editing , updating, deleting in database
and my database contains data : password,username,email ...and a text field named image url which contains each image path .
so as you see my data managing control has to include an upload control in the editing.

I'm good only in datalist and gridview
what is confusing me :
the datalist is good and easy in ordering the items
but it has no automatic pages like the gridview.

so what you advice me to choose and why
and it would be grateful if you write for me a simple code (specificly the upload control)

Thanks in advance.
Posted

1 solution

With Grid u can do lots of thing, here I have used the Telerik RadGrid , u can try with the normal asp grid, here u can do what ever u want to do



XML
<telerik:RadGrid ID="wRGEmpDocuments" runat="server" AllowSorting="true" GridLines="Both"
                                                                Width="100%" OnInsertCommand="wRGEmpDocuments_InsertCommand" OnDeleteCommand="wRGEmpDocuments_DeleteCommand"
                                                                OnItemDataBound="wRGEmpDocuments_ItemDataBound" OnNeedDataSource="wRGEmpDocuments_NeedDataSource"
                                                                Skin="WebBlue" AllowAutomaticInserts="true" AllowPaging="True" OnUpdateCommand="wRGEmpDocuments_UpdateCommand">
                                                                <PagerStyle Mode="NextPrevNumericAndAdvanced"></PagerStyle>
                                                                <MasterTableView ShowHeader="true" AutoGenerateColumns="False" AllowPaging="true"
                                                                    CommandItemDisplay="Top" DataKeyNames="SlNo" PageSize="7" HierarchyLoadMode="ServerOnDemand">
                                                                    <Columns>
                                                                        <telerik:GridBoundColumn UniqueName="DocumentName" DataField="DocumentName" HeaderText="Document Name"
                                                                            HeaderButtonType="TextButton" SortExpression="DocumentName">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn SortExpression="DocumentDescription" HeaderText="Description"
                                                                            HeaderButtonType="TextButton" DataField="DocumentDescription" UniqueName="DocumentDescription">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn SortExpression="DocumentId" HeaderText="Document" HeaderButtonType="TextButton"
                                                                            DataField="DocumentId" UniqueName="DocumentId">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridCheckBoxColumn DataField="IsActive" HeaderText="Active" HeaderStyle-HorizontalAlign="Left"
                                                                            HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Left">
                                                                        </telerik:GridCheckBoxColumn>
                                                                        <telerik:GridBoundColumn SortExpression="UploadedDoc" HeaderText="UploadedDoc" HeaderButtonType="TextButton"
                                                                            DataField="UploadedDoc" UniqueName="UploadedDoc">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-HorizontalAlign="Center"
                                                                            HeaderText="Edit" ItemStyle-HorizontalAlign="Center">
                                                                        </telerik:GridEditCommandColumn>
                                                                        <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete ?" ConfirmDialogType="Classic"
                                                                            ConfirmTitle="Delete" ButtonType="ImageButton" HeaderText="Delete" CommandArgument="SlNo"
                                                                            UniqueName="Delete" CommandName="Delete" Text="Delete" HeaderStyle-HorizontalAlign="Center"
                                                                            ItemStyle-HorizontalAlign="Center">
                                                                        </telerik:GridButtonColumn>
                                                                        <telerik:GridTemplateColumn Visible="false">
                                                                            <ItemTemplate>
                                                                                <asp:HiddenField ID="whdnIsActive" runat="server" Value='<%#   Eval("IsActive") %>' />
                                                                            </ItemTemplate>
                                                                        </telerik:GridTemplateColumn>
                                                                    </Columns>
                                                                    <ItemStyle HorizontalAlign="Left" />
                                                                    <HeaderStyle HorizontalAlign="Left" />
                                                                    <EditFormSettings EditFormType="Template" FormTableItemStyle-HorizontalAlign="Left">
                                                                        <FormTemplate>
                                                                            <table width="100%">
                                                                                <tr>
                                                                                    <td align="left" width="40%">
                                                                                        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                                                                                            <ContentTemplate>
                                                                                                <asp:TextBox ID="wtxtDocumentName" runat="server" MaxLength="25" Text='<%#   Eval("DocumentName") %>'></asp:TextBox>
                                                                                                <asp:TextBox ID="wtxtDocumentDescription" runat="server" Text='<%#   Eval("DocumentDescription") %>'></asp:TextBox>
                                                                                                <asp:CheckBox ID="chkaprvdoc" runat="server" Checked='<%# (Container is GridEditFormInsertItem) ? true : Eval("IsActive") %>' />
                                                                                            </ContentTemplate>
                                                                                        </asp:UpdatePanel>
                                                                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" Display="None"
                                                                                            ControlToValidate="wtxtDocumentName" SetFocusOnError="true" ErrorMessage="Document Name is required.."
                                                                                            ValidationGroup='<%# (Container is GridEditFormInsertItem) ? "VG" : "VG1" %>'>
                                                                                        </asp:RequiredFieldValidator>
                                                                                        <act:ValidatorCalloutExtender ID="ValidatorCalloutExtender6" runat="server" TargetControlID="RequiredFieldValidator6"
                                                                                            Width="250px" WarningIconImageUrl="../Images/001_11.png">
                                                                                        </act:ValidatorCalloutExtender>
                                                                                    </td>
                                                                                    <td align="left" width="38%">
                                                                                        <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
                                                                                            <ContentTemplate>
                                                                                                <table>
                                                                                                    <tr>
                                                                                                        <td align="left" valign="bottom">
                                                                                                            <asp:ImageButton ID="btnRevDocument" runat="server" Width="17px" Height="18px" ImageUrl="1304404807_gtk-cancel.png"
                                                                                                                CommandArgument="SlNo" CommandName="RemoveDoc" OnClick="btnRevDocument_Click"
                                                                                                                Text="Remove Document" ToolTip="Remove Document" />
                                                                                                            <asp:ImageButton ID="btnAddDocument" runat="server" Width="17px" Height="18px" ImageUrl="~/Images/1304403818_add.png"
                                                                                                                OnClick="btnAddDocument_Click" OnClientClick="showAddDoc()" Text="Add Document"
                                                                                                                ToolTip="Add Document" />
                                                                                                            <asp:Label ID="wlbluploadfilename" runat="server" Text='<%#   Eval("UploadedDoc") %>'></asp:Label>
                                                                                                        </td>
                                                                                                    </tr>
                                                                                                </table>
                                                                                                <asp:HiddenField ID="whdnUploadedDoc" runat="server" Value='<%#   Eval("UploadedDocpath") %>' />
                                                                                            </ContentTemplate>
                                                                                        </asp:UpdatePanel>
                                                                                    </td>
                                                                                    <td width="20%">
                                                                                        <asp:Button ID="btnUpdate" runat="server" ValidationGroup='<%# (Container is GridEditFormInsertItem) ? "VG" : "VG1" %>'
                                                                                            Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' />
                                                                                    </td>
                                                                                    <td>
                                                                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                                                            CommandName="Cancel" />
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        </FormTemplate>
                                                                    </EditFormSettings>
                                                                </MasterTableView>
                                                                <ActiveItemStyle HorizontalAlign="Left" />
                                                                <AlternatingItemStyle HorizontalAlign="Left" />
                                                            </telerik:RadGrid>
 
Share this answer
 
Comments
weso_f 16-Jun-11 19:23pm    
Thanks man, but do I need to write in the code behind to activate the commands ?
amit28august 17-Jun-11 0:23am    
no dude u can do all the stuff with the DataSourceID,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900