I want to select a row and column in gridview using radiobutton in gridview

I want to select a row and column in gridview using radiobutton in gridview . if which radio button is select that row will select and i want that row column values in outside individual textboxes of next page.  but in that only single radiobutton will select and no post back="true" bcz iam not using checked change property. i inserted button below gridview. if i click the that selected row and columns values are stored into textboxes of next page

im using this code .but im getting one column in that row. but i want all columns in that selected row so plz replay me 

<asp:GridView ID="Gridviewselectbus" runat="server" Height="87px"

Width="771px" BorderColor="#BFBFBF" HorizontalAlign="Center">

<RowStyle BorderColor="#999999" ForeColor="#747474" HorizontalAlign="Center"

VerticalAlign="Middle" Wrap="True" />

<EmptyDataRowStyle BorderColor="#999999" />

<Columns>

<asp:TemplateField HeaderText="Select">

<ItemTemplate>

&nbsp;<input name="MyradioButton" type="radio"

value='<%#Eval("bustype") %> />

</ItemTemplate>

</asp:TemplateField>

</Columns>

1
rajenderreddy
10/16/2008 10:31:27 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

5 Replies
4067 Views

Similar Articles

[PageSpeed] 22

just take the radio button as asp.net radio button not like input  i have changed ur code slightly for understanding  its a sample okay its working

 

source code is

 

 <asp:GridView ID="Gridviewselectbus" runat="server" Height="87px" Width="771px" BorderColor="#BFBFBF"
                HorizontalAlign="Center">
                <RowStyle BorderColor="#999999" ForeColor="#747474" HorizontalAlign="Center" VerticalAlign="Middle"
                    Wrap="True" />
                <EmptyDataRowStyle BorderColor="#999999" />
                <Columns>
                    <asp:TemplateField HeaderText="Select">
                        <ItemTemplate>
                            <asp:RadioButton id="MyradioButton" AutoPostBack ="true" runat="server"  OnCheckedChanged ="RadioButton1_CheckedChanged"  value='<%#Eval("bustype") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>

 

 

code behind

you have to bind the gridview in page load 

  protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
    {
        for(int i = 0; i < Gridviewselectbus.Rows.Count; i++)
        {
            ((RadioButton)Gridviewselectbus.Rows[i].FindControl("MyradioButton")).Text = i.ToString();

        }
        int index=int.Parse (((RadioButton)sender ).Text .ToString ());
        TextBox1.Text = Gridviewselectbus.Rows[index].Cells[1].Text .ToString();
        TextBox2.Text = Gridviewselectbus.Rows[index].Cells[2].Text .ToString();
        TextBox3.Text = Gridviewselectbus.Rows[index].Cells[3].Text .ToString();
        TextBox4.Text = Gridviewselectbus.Rows[index].Cells[4].Text .ToString();

    
    }
i have taken texbox1,2,3,4 for displaying purpose

 

 


Thanks,
Shiva

If(MyPost Helps You)
“Mark as Answer”
0
shivach7
10/16/2008 12:08:11 PM

In that radiobutton checked change means suddenly changing that page. if i want to choose which selected radiobutton is selected with out postback =true. and if i press the next button in below gridview then that select radio button row and columns will come to text boxes.

i won't use checked chang property and postback=true. im using below next button. if i press the next buton then process that selected radio button grid view row and columns values will show in textboxes  

plz tell me

0
rajenderreddy
10/16/2008 12:58:43 PM

 its working do your modifications okay

 

<asp:GridView ID="Gridviewselectbus" runat="server" Height="87px" Width="771px" BorderColor="#BFBFBF"
                HorizontalAlign="Center">
                <RowStyle BorderColor="#999999" ForeColor="#747474" HorizontalAlign="Center" VerticalAlign="Middle"
                    Wrap="True" />
                <EmptyDataRowStyle BorderColor="#999999" />
                <Columns>
                    <asp:TemplateField HeaderText="Select">
                        <ItemTemplate>
                            <asp:RadioButton id="MyradioButton"  runat="server"    value='<%#Eval("id") %>' />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Button runat ="server" Text="click"  ID="butn" OnClick="butn_Click" />
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
            <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>

 

 

code behind

 

 protected void butn_Click(object sender, EventArgs e)
    {

        for (int i = 0; i < Gridviewselectbus.Rows.Count; i++)
        {
            if (((RadioButton)Gridviewselectbus.Rows[i].FindControl("MyradioButton")).Checked == true)
            {
                TextBox1.Text += Gridviewselectbus.Rows[i ].Cells[1].Text.ToString();
                TextBox2.Text += Gridviewselectbus.Rows[i].Cells[2].Text.ToString();
                TextBox3.Text += Gridviewselectbus.Rows[i ].Cells[3].Text.ToString();
                TextBox4.Text += Gridviewselectbus.Rows[i ].Cells[4].Text.ToString();

            }

        }


Thanks,
Shiva

If(MyPost Helps You)
“Mark as Answer”
0
shivach7
10/16/2008 1:08:55 PM

I write ur code but in that select all radiobuttons.not selecting single radiobutton. in the gridview.

if (((RadioButton)Gridviewselectbus.Rows[i].FindControl(selectedValue)).Checked == true) here nullreference exception was unhadled by user code. this error came.

 and also  Error 1 'RadioButton' is an ambiguous reference between 'System.Web.UI.WebControls.RadioButton' and 'System.Windows.Forms.RadioButton.

0
rajenderreddy
10/17/2008 5:28:43 AM

Hi rajenderreddy,

Try :

if (((System.Web.UI.WebControls.RadioButton)Gridviewselectbus.Rows[i].FindControl(selectedValue)).Checked == true)



Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Samu
10/20/2008 4:42:30 AM
Reply:

Similar Artilces:

I want to select a row and column in gridview using radiobutton in gridview #2
I want to select a row and column in gridview using radiobutton in gridview . if which radio button is select that row will select and i want that row column values in outside individual textboxes of next page.  but in that only single radiobutton will select and no post back="true" bcz iam not using checked change property. i inserted button below gridview. if i click the that selected row and columns values are stored into textboxes of next page im using this code .but im getting one column in that row. but i want all columns in that selected row so plz repla...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Problem in Using DropDownList Control to select a selected row of SqlDataSource that is under GridView Control
Hi all,In my SQL Server Management Studio Express, I have a database "ChemDatabase" that has a table "LabData"  formatted in the following way: SampleID int PRIMARY KEY, SampleName nvarchar(25), ChemicalName, nvarchar(25), Concentration decimal(6.2) with 5 rows of records in this .dbo table. In my Visual Web Developer Express, I created a website "RPD-TCE" for extracting a row of record from the LabData table by using a DropDownList, a GridView and a SqlDataSource.  I want to click DropDownList to list one number of S...

Iwant to select a row and column in gridview with select radiobutton. but No checked change event.below put a button .if click that button to seleced row values will select
I want to select a row and column in gridview using radiobutton in gridview . if which radio button is select that row will select and i want that row column values in outside individual textboxes of next page.  but in that only single radiobutton will select and no post back="true" bcz iam not using checked change property. i inserted button below gridview. if i click the that selected row and columns values are stored into textboxes of next page im using this code .but im getting one column in that row. but i want all columns in that selected row so plz repla...

Using a row selection in a gridview to create database rows for another gridview
Hi there, I have 2 gridviews on a form, the first displays some template rows from a database table.  The second displays some user specific rows (with additional data added to the template info) from the same table. They both work fine for displaying the info.  Now what I want to do, is allow users to 'select' a template row on the first gridview, and have that action automatically: create a new user-specific row, with added fields from profile data etc. insert it into the table then refresh the second gridview in order to show the new added row. C...

Hide a Gridview column but use the value in that column when the row is selected.
I need to retrieve a column from my database but do not want to display it in the gridview.  However, I need to be able to show that information later in the application.  I am using the wizard control.  I believe I can use the DataKeyValues property of the gridview but can't figure out how to write the code to get the value of the cell in that column when the row is selected so it can be referenced later.  I am using VB.  Thanks for your help!! Found the answer.  Here it is in case anyone else needs it:       &nbs...

GridView.Rows(Column=ID_PK) to GridView.Rows(Column=DropDownListTeamplteField)
Hi Guys,I wonder how I can assign the PrimaryKey in each GridView Row to the template field in the same row. whereas the template field is filled with a dropdownlist thatshould show the values for retrieved in a different table through the GridView Row primary key (which serves as the SELECT parameter to get these values) The GridView looks like this:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="C_ID" DataSourceID="GetC_IDs"> <Columns> <asp:BoundField D...

Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."
and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".   Here is my event handling... protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){ try { AdhocJobGridView.DataSource = wsBaseInfoArray; AdhocJobGridView.PageIndex = e.NewPageIndex; AdhocJobGridView.DataBind(); }catch (Exception ex) {throw ex; }   Here is my aspx... <asp:GridView ID="AdhocJobGridView...

Selecting a gridview row and keeping the last selected row in a gridview highlighted after mouse moves over a new row.
What is the best way to show a gridview row highlighted once selected and keep it highlighted once the mouse moves over a different row? Thanks, Steve hi,you can use <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="#FFFFFF" /> plz let me know if i misunderstood you Thanks for your help. One problem; however, is that after the row has been selected and I check the "grid.SelectedIndex" it has a value of -1 and not the index of the row that was selected on the grid. What do you recommend? Thanks, Steve hi, sorry i din...

GridView Selection , want use column data, data is DateTime, Accessdatabase , want compare with real time date
i using access database. i have a gridview and when select the gridview, a message box will pop out if the date of today is lesser then the date in the data that is selected. Hi probotz, You can place a LinkButton into GridView as select button and handle its Click event to show popup message: <asp:TemplateField>            <ItemTemplate>              <asp:LinkButton ID="LB_select" Text="Select" CommandArgument='<%# Eval(&q...

exporting a gridview control with selected rows and columns
Hey I would liket o export only the data not the headers or the controller(edit, delete, etc) how would i go about doing so. This si my code that allows me to export in the first place!Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExport.Click   GridView1.AllowPaging = False GridView1.PageSize = 100 GridView1.DataSource = "datasourcePullInst" 'Place your datasource (datatable/dataset) 'GridView1.DataBind() Response.Clear() Response.Buffer = TrueResponse.AddHeader("Content-Disposition", "attachment...

Selecting the multiple rows in GridView and inserting the selected rows to another Gridview & Performing some operations on it
 Dear All, I have become mad for solving this problem. Please Help me. I have a Gridview bound to a datasource. I inserted the CheckBox Control in Templet to select certain rows. Gridview1 contains some products id & name.I want to insert the selected rows in to second Gridview  and in the second Gridview I need to add two more colums AdvicedQty & AcceptedQty(TextBox Cotrol).The user will select few products in Gridview1 & clicks add which will be added another gridview then in second Gridview he enters the AdviceQty & AcceptedQty.After entering the data he cli...

want to bind a gridview using the another gridview's selected item
 iam using a gridview1 which holds the feilds like (Cust_ID, date, ......). Now what i want to do is, when i click on any Cust_ID in the gridview1, it should bind the another gridview2 using the Cust_ID value, in the same page itself.... Here's a very simple example: <%@ page language="C#" masterpagefile="~/MasterPages/Default.master" autoeventwireup="true" codefile="1328980.aspx.cs" inherits="Posts_GeneralASPNET_DataPresentationControls_1328980" title="Untitled Page" %> <asp:content id="Content...

Enable Radiobutton in Gridview that has Alternate rows when edit button is clicked, using GridView.RowCreated
OK I have a gridview that has alternate rows enabled to make it look pretty :) I also have Radiobuttons in an ItemTemplate that are disabled (from editing) on the load of the gridview.  What I want to do is when I click Edit I want the radiobuttons enabled.  Well I got that part down accept every other will not enable the radio buttons.  I know I have to check the status of the row to see if it an alternate row but how would I then enable the controls on that row for edit.  Here is my code I have been playing with.   any suggestion would be great...  1 &...

Web resources about - I want to select a row and column in gridview using radiobutton in gridview - asp.net.presentation-controls

'android-widget' tag wiki - Stack Overflow
Q&A for professional and enthusiast programmers

dBase - Wikipedia, the free encyclopedia
dBase II was the first widely used database management system (DBMS) for microcomputers . It is a relational database management system. It was ...

Perl/Tk Menus: Past, Present and Future - The Perl Journal, Summer 1999
Whether they drop down as rectangles or pop up as pies, menus are widgets that managebundles of related information. Menus are pervasive, appearing ...

Index - 2,000 Things You Should Know About WPF
Below is a list of all posts created so far for the 2,000 Things You Should Know About WPF blog. Total number of posts = 1,077 Animation #7 - ...

Moonify UI - 365psd
Join our growing community of Photoshop users. Sign Up or Log In 365psd Download a free psd every day. Collections Contributors Premium Files ...

Learning Mobile Development - Android and iOS Lessons For Beginners
... Android and iOS Lessons For Beginners Menu Skip to content Home Android Tutorials IOS Tutorials Contact us Search for: Customize RadioButton ...

Basic4android (Basic for Android) - Android programming with Gui designer
Basic4android (Basic for Android) is a simple and powerful development environment for developers of Android applications.

Bravenet Webmaster Resource Center - Scripts, sounds, art and more
Cheap web hosting and free web tools. Build your website with our easy webpage builder, web tools, web services, and free website content.

Gchat - Home
Gchat - is easy to use program, suitable for communicating with friends. This non-commercial program that you can change it as you like. Program ...

Microsoft readies Silverlight 2 beta
Featured in Version 2 is a cross-platform, cross-browser version of the .Net Framework, a Microsoft official said.

Resources last updated: 2/12/2016 7:07:38 AM