CoderSource.net
Search
how can i select a row in a gridview
Started by reguapo at 04-24-2006 8:27 AM. Topic has 3 replies.

Print Search « Previous Thread Next Thread »
   04-24-2006, 8:27 AM
reguapo is not online. Last active: 4/24/2006 1:22:40 PM reguapo

Top 50 Posts
Joined on 04-24-2006
Posts 2
how can i select a row in a gridview
how can i select a row in a gridview without the select link, something like clicking in the cell or something like that?

   Report 
   04-24-2006, 11:48 AM
Yasir is not online. Last active: 11/16/2006 10:02:40 AM Yasir

Top 10 Posts
Joined on 03-15-2006
Posts 44
Re: how can i select a row in a gridview
you can do this by hooking into RowDataBound event and do the following


protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType DataRow)
{
e.Row.Attributes["OnClick"] = ClientScript.GetPostBackEventReference(this, "Select$" + e.Row.RowIndex);
}
   Report 
   04-24-2006, 1:17 PM
reguapo is not online. Last active: 4/24/2006 1:22:40 PM reguapo

Top 50 Posts
Joined on 04-24-2006
Posts 2
Re: how can i select a row in a gridview
why in the rowdatabound event?
and what does this line means:
if(e.Row.RowType == DataControlRowType.DataRow)
why did you check that
i tried with that but the row didnt select

   Report 
   04-24-2006, 8:57 PM
Yasir is not online. Last active: 11/16/2006 10:02:40 AM Yasir

Top 10 Posts
Joined on 03-15-2006
Posts 44
Re: how can i select a row in a gridview
rowdatabound is find when each row is binded against the source. anyhow if this does not work you can check the SelectedIndex property. you can set it programatically to select some index.

The if condition is to check if the row is a data row. and then i was trying to fire an event to select the row. you can use the selectedIndex property to directly select the row.
   Report 
Codersource.Net » Programming » Asp .Net Progra... » how can i select a row in a gridview

MENU
Home
MFC 
C++
.Net
WIN32
Programming
Forum
My Articles
Welcome to Codersource.Net Login | Register | Faq  

Google
 

NOTES:


Thanks for visiting our CoderSource.net. This site will be improved with more articles. Interested visitors can also submit their articles through the Submit Article link.Your article will also be published after due consideration by the editor. 

© Copyright 2003. All rights on content reserved by CoderSource.net. Contact    About Us