Selecting records in GRIDVIEW without SELECT button ??

Hi , i was wondering, how to make the SELECT link button that comes along with the GRIDVIEW when we enable SELECTION , disappear and make the records selectable ?, so that insted of CLICKING on the SELECT button for selecting the records , i could directly select the records !.

Now i get somthing like this.. for selection..

Col 1   COL2
Select name
Select Age
Select salary

What i want is..this for selection...

COL1
name
age
salary

Thanks in advance !

0
ashutosh508
9/17/2007 6:12:44 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

7 Replies
667 Views

Similar Articles

[PageSpeed] 35

Convert your data column to a template field. Replace the label with a LinkButton, bind the text and set the commandname of the button to Select.

Tim

0
cashmore
9/17/2007 7:28:46 PM

If you want to use a radio button to do the select in a GridView you may use the following code (updated for correct display):

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected string IsChecked(Object key)
    {
        if (YourGridView.SelectedDataKey != null)
            if (key.Equals(YourGridView.SelectedDataKey.Value))
                return "checked";
        return "";
    }

    protected void YourGridView_SelectedIndexChanged(object sender, EventArgs e)
    {
        YourGridView.DataBind();
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView runat="server" DataKeyNames="YourId" DataSourceID="YourDataSource"
            ID="YourGridView" OnSelectedIndexChanged="YourGridView_SelectedIndexChanged">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="SelectLinkButton" runat="server" CausesValidation="False" CommandName="Select">
                        <input name="SelectGroup" type="radio"
                                <%# IsChecked(Eval("YourId")) %>
                                onclick="eval(this.parentNode.href)" ></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                .
                .               
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
</html>

 
0
attractor
5/4/2008 4:48:59 AM

^^^^^^

The code above should fix radio display problems. In the above code I use the javascript postback method of the parent element which is a Select LinkButton to postback the selected index changing event. I also use some inline code to emit the cheched or nothing attribute for input element by comparing the Id of the current row against the id of the selected row. In order for that to be sucesfull the GridView needs to databind everytime we change the selected index.

0
attractor
5/4/2008 5:39:13 PM

Hi.. Iam Entry Level Prg in C#...

 

 My Database Contain

  Id  Name  Address  Area  City..

  1 MM       MMM     mmm  mmm

  2  RR      RR         RR      RRRR

 First Show the Id Number in Gridview...

wen i click the Id Number Show related items...

For Ex i click 2 Id means to display Name, Address,Area and city in same gridview and as wel as another one gridview...

 

Its Possible Plz Give me solution for my doubt.......

 

Thaks......

 

 

 

 

 

  

0
kannanmca
7/4/2008 8:26:13 AM

It looks like this tutorial may help:

 http://www.asp.net/learn/data-access/tutorial-10-vb.aspx

 Now if instead of using the "Select" button you can make the "Id" field a template as follows:

                     <ItemTemplate>
                        <asp:LinkButton ID="SelectLinkButton" runat="server" CausesValidation="False" CommandName="Select" Text='<%# Eval("Id")>' / >
                    </ItemTemplate>

0
attractor
7/4/2008 4:47:11 PM

hi  attractor,

   Thks for reply...

i need selecting records from gridview using without select button ... this is i need... If u no that, tel me...

                         Regards.

                          kannan

 

0
kannanmca
7/5/2008 6:30:15 AM

kannanmca:

hi  attractor,

   Thks for reply...

i need selecting records from gridview using without select button ... this is i need... If u no that, tel me...

                         Regards.

                          kannan


That is what I am telling you in my previous message. I though you wanted to select a record by pressing on the Id field in the GridView. You can achieve that by making the field a template and converting the field to a link button with "Select" as CommandName. Good luck.

0
attractor
7/5/2008 4:52:55 PM
Reply:

Similar Artilces:

Select a gridview row without a select button
Hi Does anyone have a vb code sample of how to select a gridview row without having to click on a select button?   Thanks    ASPX <asp:label id="Label1" runat="server" /> <asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" datakeynames="ProductID,ProductName" datasourceid="SqlDataSource1" style="margin-top: 12px;"> <columns> <asp:boundfield datafield="ProductID" headertext="ProductID" readonly="True" sort...

Problem in GridView Row Selection without using Select button
Hi All, I want to Select a Gridview Row without using Select button, So i have used following Javascript in Row DataBound Event.... e.Row.Attributes["onmousedown"] = ClientScript.GetPostBackClientHyperlink(this.grdDocs, "Select$" + e.Row.RowIndex,false); It is working fine. But the page is refreshing every time when i select a row. how can i avoid that....? Using an UpdatePanel is one option, off the top of my head,C# <---> VB.Net Translator I am not using Ajax here. Can't i do with Javascript...? Row selection in a Grid is only handled server-side...

change selected index in gridview without clicking the select link/button
Hey guysI’ve a question regarding gridviews and Urls.Assuming I’ve a URL like that http://yourdomain.com/pagename.aspx?GUID=0a502fda-3e41-4f3b-8407-7024dda832a8According to the guid in the URL I want a certain row in a gridview which has the giud as value in some column.Getting the guid from the URL isn't very complicated so far.  protected void Page_Load(object sender, EventArgs e) { System.Uri url = new System.Uri(Request.Url.ToString()); System.Guid _guid = Guid.Empty; if (Request.QueryString.Count != 0) { ...

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...

How to select a row without select button
Hi. I am use one Dataview in My Web site Now i Have 2 boubts , 1.How to get a Datagrid item values(All row values)in pageLoad event 2.How to select a row without using Select Button, i want to select a row on mouse click event Please give me a soulation TO SELECT A ROW ONCLICK: Firstly, you will need to enable row selections for your datagrid. this will place the proper javascript in your page for what is to come.  This will place a select button on your page, but you can convert that column into a template and make the linkbutton visible=false. you need a OnRowCreated ev...

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...

How to display the more than one row with items and buttons in gridview control. when i select three items at same time from categories(Fruits, Apples, Gifts). The selected items are displayed in g
Hi,when i select three items at same time from categories(Fruits, Apples, Gifts). The selected items are displayed in gridview.Here i would like to change this way "when i click more than one category at same time. it should be display selected item and button."For example: if i have to select Fruits, Apples from categories.  it should be display like 1st "row have Fruits and In 2nd row have Apples and button" in gridview.the button have some event.How can i do it? Please can anyone answer me.With kind requestThanks your query is very raw..can u details it out...Pl...

Altering the Select.Text of the GridView Select button
I want to change the default text of the GridView Select button from "Select". As you see, I used AutoGenerateSelectButton="True". When "False" there are several examples (the links) on how to do that. Can I still change it somehow in the "true" state? <asp:GridView ID="GridView2" runat="server" Style="left: 0px; position: absolute;    top: 0px" Width="456px" SelectedIndex="0"     OnSelectedIndexChanged="GridView2_SelectedIndexChanged"  ...

Select button in Gridview deletes instead of selecting
 For some reason my gridview wants to delete instead of selecting my record.Here is my code: <asp:GridView ID="ValidateGridView" runat="server" AutoGenerateColumns="False"         DataSourceID="NieuwsValiderinObjDS"         onselectedindexchanged="ValidateGridView_SelectedIndexChanged"        OnRowCommand="ValidateGridView_RowCommand"        OnRowDataBound="ValidateGridView_RowDataB...

Selectable Row in a DataGrid without the SELECT button
Does anyone know how to code the DataGrid so that when click on the data row, that row  must be selected just like a SELECT button does, but without the button?   Thanks, Check this out: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebteam/html/webteam11062001.asp (Section: The Works and Days of Hands)Remove "_no_spam" for sending email...

Problem with modalpopupextender and gridview select with no select button
I am trying to utilize a gridview configured to use a row select with no select button. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { // Add the javascript that will do the callback when a user clicks on a row // Header and footer rows should not have callbacksif (e.Row.RowType == DataControlRowType.DataRow) {e.Row.Attributes.Add("onmouseover", "Highlight_On(this);"); e.Row.Attributes.Add("onmouseout", "Highlight_Off(this);");e.Row.Style["cursor"] = "hand";e.Row.Attributes["onclick"...

how can i select a row in a gridview without the select link
how can i select a row in a gridview without the select link, i mean, by click in the row no in the select link?i know that it is not a custom control but i couldnt do that yet. Hi, it is a custom control. ;-) Please see my blog post: Developing a row-clickable GridViewhttp://aspadvice.com/blogs/joteke/archive/2006/01/07/14576.aspxThanks,Teemu KeiskiFinland, EU...

My detailview is not loading the selected value when I select a record from a Gridview
Hello,This is what i have until now,there is a gridview1 which is the parent table, when the user selects a record from it the sons are loaded in another gridview2, (that is working fine), but that gridview2 also has sons which are supposed to be loaded when selecting a record from it, in a detail view.  The gridview2 sends two parameters to the detailview, plus a session parameter which it receives.  The problem is that the detail view loads only one record, and eventhough you change the selected record in the gridview2 the details do not change.It doesnt gives any error message.&...

Help selecting geridview row without select button.
I am trying to get a gridview row to be selected without havigna select button.  I have looked all over and come up with this notion.  In the Gridview I do the following.                  <asp:TemplateField HeaderText="ContactID" Visible="False">                    <ItemTemplate>                &n...

Web resources about - Selecting records in GRIDVIEW without SELECT button ?? - asp.net.presentation-controls

Consultation Document on the Methods for Selecting the Chief Executive and for Forming the LegCo in 2012 ...
The " Consultation Document on the Methods for Selecting the Chief Executive and for Forming the LegCo in 2012 " was a document published on ...

Voting Machine Caught on Camera Casting Ballot for Democrat when Selecting Republican - YouTube
**UPDATE.... I've heard many reports that this is "just a calibration issue." I will say this... when I went to page 2 and began voting for city ...

Selecting The Right Jeans
Fit, style, cut, colour and wash all factor into the pursuit for great denim.

Clock ticking on selecting successor to Leigh Clifford at Qantas
With Qantas on course to chalk up its largest annual profit since 2008, the question now is whether chairman Leigh Clifford is looking to hang ...

Why are the reserves selecting the team?
Backbenchers are the reserves of the parliamentary system. They are newcomers.

Jackie French: Why selecting the right place for your plants is important
The secret of growing anything easily is to choose the best spot for what you want to grow.

Netflix turns to pirates when selecting new shows
Imagine the surprise, then, when the popular video streaming site admitted that it actually turns to torrenters for inspiration. "With the purchase ...

Boston Marathon bombing trial: Judge, lawyers face challenges in selecting jurors - CTV News
As the second phase of jury selection began in the federal death penalty trial of Boston Marathon bombing suspect Dzhokhar Tsarnaev, it immediately ...

Selecting cabinet one of first orders of business for Trudeau
One of the first orders of business for any new prime minister is picking a cabinet. Who is likely to make the cut?

Agile Analysis, Self-Selecting Teams, TDD & BDD in Methods & Tools Winter 2014 issue
... for software developers, testers and project managers – has just published its Winter 2014 issue that discusses Agile Analysis, Self-Selecting ...

Resources last updated: 12/29/2015 4:12:18 AM