-
Dec 2nd, 2018, 11:10 AM
#1
Thread Starter
Fanatic Member
Gridview select
I have a web page with a Gridview control and I wish to select one of the rows without using a button or select column.
I have tried the following two events, but none of them work. The Gridview does not know that it must select a row - or - nothing happens when I click the row:
Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged
Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs)
Any help will be appreciated,
Thanks
PK
-
Dec 6th, 2018, 08:54 AM
#2
Re: Gridview select
Hi,
You may use JavaScript/jQuery to achieve that.
- kgc
-
Dec 6th, 2018, 08:58 AM
#3
Re: Gridview select
Hi,
You may use JavaScript/jQuery to achieve that.
- kgc
-
Dec 6th, 2018, 09:54 AM
#4
Thread Starter
Fanatic Member
Re: Gridview select
Thanks, but I have no idea how to write Java. Sorry.
-
Dec 7th, 2018, 02:06 AM
#5
Re: Gridview select
Java is different from JavaScript/jQuery. JavaScript/jQuery interacts with ASP.NET in the client/browser side.
Another option below is to add a javascript onclick to a gridview row on render event. But still, i prefer writing scripts on the front-end side.
Code:
protected override void Render(HtmlTextWriter writer)
{
foreach (GridViewRow r in GridViewEmployees.Rows)
{
if (r.RowType == DataControlRowType.DataRow)
{
r.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridViewEmployees, "Select$" + r.RowIndex,true);
}
}
base.Render(writer);
}
- kgc
-
Dec 7th, 2018, 06:00 AM
#6
Thread Starter
Fanatic Member
Re: Gridview select
Hi KGComputers,
I appreciate your help.
However, the code you have given, I think, is in C#.
I need to combine two fields of ACCESS in one column of my Gridview in code behind - combining the 'article name' with the 'URL link' anchor.
Thanks
PK
-
Dec 8th, 2018, 10:20 AM
#7
Re: Gridview select
Yeah, I've not written ASP.NET Webforms using VB.NET for years now. Most of the web projects that I'm involved with are in C#. However, the logic I've given can be converted to VB.NET if you want to.
Code:
I need to combine two fields of ACCESS in one column of my Gridview in code behind - combining the 'article name' with the 'URL link' anchor.
If this is another question, you may want to ask this in a separate thread.
- kgc
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|