Skip to content

Commit bcba70b

Browse files
authored
Update README.md
1 parent 7ccf7f3 commit bcba70b

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,66 @@
11
# Blazor.WebForm.Components
22
ASP.NET Web Forms System.Web.UI.WebControls Razor Components For Blazor WebAssembly.
3+
4+
5+
<pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: &quot;Source Code Pro&quot;, Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code class="language-cs hljs" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; border: none; display: block; font-family: &quot;Source Code Pro&quot;, Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;">@using System.Web.UI;
6+
@using System.Web.UI.WebControls;
7+
@page "/fetchdata-gridview"
8+
@inherits ControlComponent
9+
@inject HttpClient Http
10+
11+
&lt;div&gt;
12+
&lt;h1&gt;Weather forecast (GridView)&lt;/h1&gt;
13+
&lt;asp.Button Text="Load Data" OnClick="this.Button_Click"&gt;&lt;/asp.Button&gt;
14+
&lt;hr /&gt;
15+
&lt;asp.Label @ref="this.label"&gt;&lt;/asp.Label&gt;
16+
&lt;br /&gt;
17+
&lt;asp.GridView @ref="this.gridview" AutoGenerateColumns="false" CssClass="table" AllowPaging="true"
18+
PageSize="2" OnPageIndexChanging="this.GridView_PageIndexChanging"&gt;
19+
&lt;Columns&gt;
20+
&lt;asp.BoundField HeaderText="Date" DataField="Date" DataFormatString="{0:yyyy/M/d}"&gt;&lt;/asp.BoundField&gt;
21+
&lt;asp.BoundField HeaderText="Temp. (C)" DataField="TemperatureC"&gt;&lt;/asp.BoundField&gt;
22+
&lt;asp.BoundField HeaderText="Temp. (F)" DataField="TemperatureF"&gt;&lt;/asp.BoundField&gt;
23+
&lt;asp.BoundField HeaderText="Summary" DataField="Summary"&gt;&lt;/asp.BoundField&gt;
24+
&lt;/Columns&gt;
25+
&lt;/asp.GridView&gt;
26+
&lt;/div&gt;
27+
28+
@code {
29+
private WeatherForecast[] forecasts;
30+
private Label label;
31+
private GridView gridview;
32+
33+
protected async void Button_Click(object sender, EventArgs e)
34+
{
35+
forecasts = await Http.GetFromJsonAsync&lt;WeatherForecast[]&gt;("sample-data/weather.json");
36+
37+
label.Text = DateTime.Now.ToString();
38+
39+
gridview.PageIndex = 0;
40+
gridview.DataSource = forecasts;
41+
gridview.DataBind();
42+
43+
this.RequestRefresh();
44+
}
45+
46+
protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
47+
{
48+
gridview.PageIndex = e.NewPageIndex;
49+
gridview.DataBind();
50+
}
51+
52+
public class WeatherForecast
53+
{
54+
public DateTime Date { get; set; }
55+
56+
public int TemperatureC { get; set; }
57+
58+
public string Summary { get; set; }
59+
60+
public int TemperatureF =&gt; 32 + (int)(TemperatureC / 0.5556);
61+
}
62+
}</code></pre>
63+
64+
65+
66+
<a href="https://www.nuget.org/packages/Blazor.WebForm.Components/">https://www.nuget.org/packages/Blazor.WebForm.Components/</a>

0 commit comments

Comments
 (0)