1 Replies - 5235 Views - Last Post: 12 August 2013 - 11:42 AM Rate Topic: -----

#1 itzmePoulami  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 12-March 13

Button field column in gridview

Posted 08 August 2013 - 10:59 PM

I have a gridview where i have only one column, i.e, 1 button field column that displays the list of folders in a particular drive in my machine. What i want to do is that when I click on a particular row of the button field column, the files inside it get displayed in another gridview. How am I supposed to get the click event of the button field column? I read about Gridview row_command event but i'm not sure how to use it. Please help.


Here's is the gridview designer code:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowcreated="GridView1_RowCreated" CssClass ="gridview" GridLines="None"
BackImageUrl="~/Images/background.jpg" onrowcommand="GridView1_RowCommand">
<Columns>
<asp:ButtonField ButtonType="Button" DataTextField="Text" CommandName="Show" >
<ControlStyle CssClass="buttons" />
</asp:ButtonField>

</Columns>
</asp:GridView>

Is This A Good Question/Topic? 0
  • +

Replies To: Button field column in gridview

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 444
  • View blog
  • Posts: 1,492
  • Joined: 28-April 09

Re: Button field column in gridview

Posted 12 August 2013 - 11:42 AM

since your CommandName on the button is "Show" you would need to check for that in the gridview's RowCommand event. The EventArgs passed into the RowCommand event contains a reference to the CommandName from the object that initiated the request.

if (e.CommandName == "Show")
{
    // Perform action for Show
}



You can also pass arguments by using the button's CommandArgument property.

This post has been edited by Nakor: 12 August 2013 - 11:43 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1