.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

A Simple and Extensible Radio Button Style GridView

Posted By: Rahul     Posted Date: December 31, 2009    Points: 2   Category :ASP.Net
The GridView is one of the significant controls in ASP.NET 2.0 and later versions. No doubt it reduces a lot of work time. However, customizing the GridView control is not an easy task. For example, it's hard to add a radio button column to the GridView. This article demonstrates the reason why a radio button column cannot act as normal and how to create a simple and extensible radio button GridView.

View Complete Post

More Related Resource Links

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

Gridview radio button

I am making an online train reservation system. I want to create a fare table (as seen in the link ) that will display fare of different classes based on the user selection of route. The fares should provide a radio button that will allow users to select which fare they would want to purchase. I am having trouble on how to show fares of the same schedule of different classes. I want to create something like the Eurostar fare tables. 

Selecting One Radio Button In A GridView

Hello, how do I add a RadioButton column to a gridview so that only one button is selectable? Here is what I have now. <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:RadioButton ID="RadioButton2" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:HyperLinkField DataTextField="Text" DataNavigateUrlFields="NavigateURL" /> </Columns> </asp:GridView>  

radio button in gridview not storing the selected value


hi i have a grid view with radio button...schedule/approve/reject...by defualt schedule radio button is selected....but when i chage radio button selection option to anyth other than schedule it still store only schedule in DB.wats the pblm?could someone help me>

<asp:GridView ID="Gridgpapp"  runat="server" DataSourceID="ApprovalGp" AutoGenerateColumns="False" 
            AllowPaging="True" AllowSorting="True" BorderColor="#3366CC" BackColor="White" BorderStyle="None" 
            BorderWidth="2px" CellPadding="4" ShowFooter="True" EmptyDataText = "No Gatepass waiting for Approvals">
              <RowStyle BackColor="White" ForeColor="#003399" />
                   <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                   <PagerStyle BackColor="#99CCCC"  HorizontalAlign="Left" />
                   <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                   <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />

Gridview with Radio Buttons

As now, Radio buttons are HTML controls, I am not able to get it on server side. When user select any radio button and press submit, Control will not available at code behind, you can use "e.Item.FindControl" as it is not "runat='server'". I want ID "Primary Key" value for selected radio button. To achive this I took the help of Javascript. I wrote javascript function that sets the values of "Primary Key" in hidden field when user clicks on any radio button. Now when user clicks on Submit button, user can get selected value froim hidden field.

Radio Button Event

Here I have explained the events of radio button with javascript.
Let me explain the scenarion first,
We are having two radio button say radioobtn1 and radiobtn2. If I click on the button 1 then I need to show one DIVor FORM. same as when I click on radiobtn 2. I have given the code for the above scenarion.

Gridview with Image Button


i have a gridview and i want to perform edit and delete with an image button

but unable to figure out the events and how i m gonna make my grid into edit mode ??

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                <asp:TemplateField HeaderText="S.No">
                        <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex+1 %>'></asp:Label>
                <asp:TemplateField HeaderText="Edit">
                        <asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Middle" 
                            ImageUrl="~/image/ico_edit.gif" CommandName="Edit" 
                            onclick="ImageButton1_Click" />
                <asp:TemplateField HeaderText="Delete">

Select only one radio button in a datagrid


I have been frantically searching for help to select only one radio button in datagrid and deselect the other when a new button is clicked.

I do not want to use javascript. Can someone help me on this?

GridView Question - Please Help Me...Should Be Simple...

Hello,I have what I think should be a simple GridView question but I can't find the answer.When I want to update a row in Gridview I click on the "Edit" link.  It takes me into the row of the GridView where I can edit the values.Here's how it looks:   CustomerID CompanyName Edit 001 IBM Microsoft Apple Google Edit 002 IBM Microsoft Apple Google Edit 003 IBM Microsoft Apple Google Edit 004 IBM Microsoft Apple Google When I click on "Edit" it looks like:   CustomerID CompanyName Edit 001 IBM Microsoft Apple Google Update Cancel IBM Microsoft Apple Google Edit 003 IBM Microsoft Apple Google Edit 004 IBM Microsoft Apple Google As you can see, I now have the ability to update the CustomerID.  I don't the user to be able to update the CustomerID, only the CompanyName via the DropDown.How can I change the GridView to ONLY allow me to update the CompanyName?ThanksJason   CustomerID CompanyName Edit 001 IBM Microsoft Apple Google Edit 002 IBM Microsoft Apple Google Edit 003 IBM Microsoft Apple Google Edit 004 IBM Microsoft Apple Google

Repeater and Gridview with select button

Hello every oneI have the following issue:I have a repeater that iterates over a datasource, and each detail of the datasource has a type of control or entry method, I have an enum to represent the type of controlenum ENTRY_METHOD : byte { SINGLE_SELECT = 1, MULTIPLE_SELECT = 2, OPEN_TEXT = 3, FLEXI_SELECT = 4 }And I have this in the repeater's ItemCreated event: switch (EntryMethod) { case ENTRY_METHOD.SINGLE_SELECT: break; case ENTRY_METHOD.MULTIPLE_SELECT: break; case ENTRY_METHOD.OPEN_TEXT: break; case ENTRY_METHOD.FLEXI_SELECT: break; default: break; }This is the aspx file:<asp:Repeater ID="RptUserDefinedInfo" runat="server" OnItemCreated="RptUserDefinedInfo_ItemCreated"> <ItemTemplate> <div style="width: 30%; display: inline-block; vertical-align: top; margin: 10px;"> <asp:HiddenField ID="HddUDTypeID" runat="server" Value='<%#Eval("UDTypeID") %>' /> <asp:HiddenField ID="HddEntryMethod" runat="server&q

gridview filtering using a codebehind (textbox + search button)

i am trying to replicate the following sequence: input text into text box > press search button > search a database using LIKE operator > display using a gridview or listview. this sequence is fairly easy to do using the drag and drop then sqldatasource options, but i am trying to do the same result using a codebehind.  here is my code:   ____________________________________________________________________________________________________________ SqlConnection myConn; myConn = new SqlConnection(@"Data Source=.\SQLEXPRESS; AttachDbFilename=|DataDirectory|\projectDB.mdf; Integrated Security=True;User Instance=True"); myConn.Open(); string strSQL; strSQL = "SELECT * FROM Message";       //strSQL = "SELECT * FROM Message WHERE Message LIKE '" + txtSearch.Text + "'"; SqlDataAdapter da = new SqlDataAdapter(strSQL, myConn); DataSet ds = new DataSet(); da.Fill(ds, "Message"); GridView1.DataSource = ds; GridView1.DataBind(); myConn.Close(); _____________________________________________________________________________________________________________  now, if I use this code inside a page_load event, it does work. if I put it inside a button_click event i get nothing. i am mystified by this.. any help? why can't i use a button to display my gridview1 when i'm using a code behind.  

Radio button and Checkbox don't work in Opera

I have a webform with 2 radio buttons and 1 checkbox. These work in IE and FireFox, but theye never get checked in Opera. Is this some problem with Opera or with my checbox/radio button?ThanksI have the following code:<asp:CheckBox ID="ckTermsNConditions" runat="server" Checked="false" /><asp:RadioButtonList ID="rblRegistrationType" runat="server" CellPadding="2" CellSpacing="2"  >                        <asp:ListItem Value="Vendor" Selected="False">How to</asp:ListItem>                        <asp:ListItem Value="Consultant" Selected="False">Feedback</asp:ListItem>                        <asp:ListItem Value="User" Selected="False">Question</asp:ListItem></asp:RadioButtonList>

Use Data in a Column as Select Button in GridView

I don't want to use the built in "Select" hyperlink that's in the gridview, I'd like to just use the first data column, is there a way to do that or are we forced to use the automatically generated "Select" column.Thanks!

Gridview and delete option - Button click displays message

Hi, I have a gridview connected to a sql database that allows the user to delete the record. I used the ASP.net automatic "options" for this. However, I would like when the user deletes a record, a message (textbox) appears in the form to say the record has been deleted. Please can anyone provide some sample codes?   Thanks in advance. Nijojo.

Update a field in a gridview to False on a Button Click

 Hi, Ive got a list of records in a gridview (from an SQLDataSource) where a field value is set to True.  I've also added a "reset" button in a template field at the start of the row in the Gridview. What I would like to do is allow the user to click the reset button on a particular row and 'reset' the true value to 'false' (updating the source data). Are there any idiot proof tutorials to do this??? Many thanks for your help! Fiorano
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend