I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
Step-1 : First bind your GridView using SqlDataSource control
Step-2 : Select 'Edit Column' link using show smart tag.
Step-3 : Now, Appear new field window, which is contain two pane (left or right).
Step-4 : Remove All selected field in left pane.
Step-5 : Add new HyperLink field From Left pane.
Step-6: After Added Hyperlink field , you can set DataTextField and DataNavigationUrl field property from right pane.
Step-7 : Click ok
Step-8: Run You application
Step-2 : Select 'Edit Column' link using show smart tag.
Step-3 : Now, Appear new field window, which is contain two pane (left or right).
Step-4 : Remove All selected field in left pane.
Step-5 : Add new HyperLink field From Left pane.
Note : Assign Table column name to DataTextField and DataNavigationUrlField.
Step-8: Run You application
Code Generate the following output
Generated Code are:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="int" DataSourceID="SqlDataSource1" GridLines="None" Width="43px">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="address" DataTextField="name"
Text="Fav. Links" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
SelectCommand="SELECT * FROM [Table1]"></asp:SqlDataSource>
</form>
</body>
</html>
Comments
Post a Comment