Click here to Skip to main content
15,904,500 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

see this question [http://www.codeproject.com/Questions/234311/deleting-rows-from-gridview]
In the orange sourcesection an example is given.
 
Share this answer
 
Try This

ASPX Page:

XML
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
C#
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);
            }
        }
    }
}
 
Share this answer
 
v3

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