asp.net中的Gridview问题 [英] Gridview problem in asp.net
本文介绍了asp.net中的Gridview问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨...
我想在网格视图的最后一行中添加单选按钮,并单击单选按钮,我想在同一行中显示3个文本框.
如果可以的话,在asp.net中可以吗?
请回复
感谢
hi...
i want to add radio button in last row of grid view and on click of radio button i want to show 3 text boxes in same row..
Is this possible in asp.net??if yes How we can do this???
please reply
thanks
推荐答案
看到此问题 [
see this question [http://www.codeproject.com/Questions/234311/deleting-rows-from-gridview]
In the orange sourcesection an example is given.
尝试一下
ASPX页面:
Try This
ASPX Page:
ASPX Page:
<pre lang="text"><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestGridView.aspx.cs" Inherits="LibraryManagement.TestGridView" %>
<!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>
<asp:GridView runat="server" ID="gv">
<Columns>
<asp:TemplateField>
<ItemTemplate >
<asp:RadioButton runat="server" AutoPostBack="true"
oncheckedchanged="RadioButton1_CheckedChanged" GroupName="A" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>
</pre>
使用系统进行代码隐藏
Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace LibraryManagement
{
public partial class TestGridView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridBind();
}
}
private void GridBind()
{
DataTable dt = new DataTable();
dt.Columns.Add("Column1");
dt.Rows.Add("row1");
dt.Rows.Add("row2");
gv.DataSource = dt;
gv.DataBind();
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
RadioButton rb = (RadioButton)sender;
if (rb.Checked == true)
{
GridViewRow gvRow = (GridViewRow)rb.Parent.Parent;
TableCell td=new TableCell();
TextBox t1 = new TextBox();
TextBox t2 = new TextBox();
TextBox t3 = new TextBox();
td.Controls.Add(t1);
td.Controls.Add(t2);
td.Controls.Add(t3);
gvRow.Cells.Add(td);
}
}
}
}
这篇关于asp.net中的Gridview问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文