aspx页面:
<asp:GridView ID=”RadioGV” runat=”server” AllowPaging=”true” PageSize=”5″ OnRowDataBound=”RadioGV_RowDataBound” > <Columns> <asp:TemplateField HeaderText=”选择”> <ItemTemplate> <asp:Literal ID=”RadioButtonMarkup” runat=”server”></asp:Literal> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
cs页面:
protected void RadioGV_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { Literal output = e.Row.FindControl(“RadioButtonMarkup”) as Literal; output.Text = string.Format(“<input type=\”radio\” name=\”ProductGroup\” ” + “id=\”RowSelector{0}\” value=\”{0}\”" ,e.Row.RowIndex); } } 这样就可以添加onclick事件,判断selectchange() [...]
Web窗体编程
ASP.NET是建立在HTTP协议之上,利用HTTP命令和策略建立双向的、浏览器到服务器(B/S)的通信和协作。ASP.NET与其他Web开发技术的最大不同在于它所提出的抽象编程模型(Abstract Programming Model)——Web窗体模型。
Web窗体模型是ASP.NET实现的典型范式,浏览器将一个表单提交给Web服务器,然后会接收到返回的完整标记页面。
阅读全文 必需知道的asp.net(节选)
In its very basic form, Viewstate is nothing more than a property which has a key/value pair indexer:
1: Viewstate[“mystringvariable”] = “myvalue”;
2: Viewstate[“myintegervariable”] = 1;
As you can see, the indexer accepts a string as a key and an object as the value. The ViewState property is defined in the “System.Web.UI.Control” class. Since all ASP.NET pages and controls derive from this class, they all have access to the ViewState property. The type of the ViewState property is “System.Web.UI.StateBag”.
The very special thing about the StateBag class is the ability to “track changes”. Tracking is, by nature, off; it can be turned on by calling the “TrackViewState()” method. Once tracking is on, it cannot be turned off. Only when tracking is on, any change to the StateBag value will cause that item to be marked as “Dirty”.
Info: In case you are wondering (and you should be) about the reason behind this “tracking” behavior of the StateBag, do not worry; this will be explained in detail along with examples about how tracking works, in the next sections.
阅读全文 ASP.NET Internals: Viewstate and Page Life Cycle(ViewState和页面生命周期介绍)