Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET 1.1 DataGrid Question

Reply
Thread Tools

ASP.NET 1.1 DataGrid Question

 
 
=?Utf-8?B?SG9seXNtb2tl?=
Guest
Posts: n/a
 
      07-25-2006
Hello,

I have a datagrid with linkbutton on the first column which shows a number
Id to select a particular record. Currently the users have to click on the
number (column1) to select. Instead, I want to change this behaviour to
rowclick. I mean the users can click on any columns of that row to select a
particular record.

Remember I got to use LinkButton on the first column always.

TIA,
Holy

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-25-2006
Handle ItemDataBound event like this:

' Visual Basic
Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
Dim itemType As ListItemType = e.Item.ItemType
If ((itemType = ListItemType.Pager) Or _
(itemType = ListItemType.Header) Or _
(itemType = ListItemType.Footer)) Then
Return
Else
Dim button As LinkButton = _
CType(e.Item.Cells(0).Controls(0), LinkButton)
e.Item.Attributes("onclick") = _
Page.GetPostBackClientHyperlink(button, "")
End If
End Sub

// C#
private void DataGrid1_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType itemType = e.Item.ItemType;
if ((itemType == ListItemType.Pager) ||
(itemType == ListItemType.Header) ||
(itemType == ListItemType.Footer))
{
return;
}
LinkButton button = (LinkButton)e.Item.Cells[0].Controls[0];
e.Item.Attributes["onclick"] =
Page.GetPostBackClientHyperlink(button, "");



}

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Holysmoke" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have a datagrid with linkbutton on the first column which shows a number
> Id to select a particular record. Currently the users have to click on the
> number (column1) to select. Instead, I want to change this behaviour to
> rowclick. I mean the users can click on any columns of that row to select
> a
> particular record.
>
> Remember I got to use LinkButton on the first column always.
>
> TIA,
> Holy
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?SG9seXNtb2tl?=
Guest
Posts: n/a
 
      07-26-2006
Thank you. It works fine.

"Eliyahu Goldin" wrote:

> Handle ItemDataBound event like this:
>
> ' Visual Basic
> Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
> ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
> Handles DataGrid1.ItemDataBound
> Dim itemType As ListItemType = e.Item.ItemType
> If ((itemType = ListItemType.Pager) Or _
> (itemType = ListItemType.Header) Or _
> (itemType = ListItemType.Footer)) Then
> Return
> Else
> Dim button As LinkButton = _
> CType(e.Item.Cells(0).Controls(0), LinkButton)
> e.Item.Attributes("onclick") = _
> Page.GetPostBackClientHyperlink(button, "")
> End If
> End Sub
>
> // C#
> private void DataGrid1_ItemDataBound(object sender,
> System.Web.UI.WebControls.DataGridItemEventArgs e)
> {
> ListItemType itemType = e.Item.ItemType;
> if ((itemType == ListItemType.Pager) ||
> (itemType == ListItemType.Header) ||
> (itemType == ListItemType.Footer))
> {
> return;
> }
> LinkButton button = (LinkButton)e.Item.Cells[0].Controls[0];
> e.Item.Attributes["onclick"] =
> Page.GetPostBackClientHyperlink(button, "");
>
>
>
> }
>
> --
> Eliyahu Goldin,
> Software Developer & Consultant
> Microsoft MVP [ASP.NET]
>
> "Holysmoke" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > I have a datagrid with linkbutton on the first column which shows a number
> > Id to select a particular record. Currently the users have to click on the
> > number (column1) to select. Instead, I want to change this behaviour to
> > rowclick. I mean the users can click on any columns of that row to select
> > a
> > particular record.
> >
> > Remember I got to use LinkButton on the first column always.
> >
> > TIA,
> > Holy
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams ASP .Net 0 03-02-2004 08:35 PM
RE: Datagrid: how cut short display of a long description in a datagrid column =?Utf-8?B?U3VyZXNo?= ASP .Net 0 03-02-2004 08:31 PM
datagrid in datagrid BK Kim ASP .Net 1 03-02-2004 06:34 AM
Call Datagrid Command column outside datagrid Dave ASP .Net 0 11-20-2003 11:11 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments