Results 1 to 5 of 5

Thread: Button column in datagrid

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    334

    Button column in datagrid

    what am I missing?! Im trying to add a column with an "edit" button into my datagrid?!

    'html creating datagrid
    <asp:datagrid id="DataGrid1"
    style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 280px"
    runat="server" Width="720px" Height="20px" Font-Size="10pt" Font-Names="Arial"
    AutoGenerateColumns="False"
    OnItemCommand="Click_Grid">

    <Columns>
    <asp:BoundColumn DataField="PickListNo" HeaderText="Pick List"></asp:BoundColumn>
    <asp:BoundColumn DataField="Type" HeaderText="Pick List Type"></asp:BoundColumn>
    <asp:BoundColumn DataField="Description" HeaderText="Stage Description"></asp:BoundColumn>
    <asp:ButtonColumn Text="Edit" ButtonType="PushButton"></asp:ButtonColumn>
    </Columns>

    </asp:datagrid>

    ' sub from vb code:
    Sub Click_Grid(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
    Label5.Text = "You selected " _
    & E.Item.Cells(2).Text & " " _
    & E.Item.Cells(1).Text & "<BR>"

    DataGrid1.Visible = False
    End Sub

    When I run the form, it seems to not relate the two together, and does nothing... what am I doing wrong... I have following several links but cant seem to see what is wrong!

  2. #2
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: Button column in datagrid

    Hi,

    You can use the DatagridColumnCollection.Add Method, here's the link;

    http://msdn2.microsoft.com/en-us/lib...ction.add.aspx

    Hope it helps,

    sparrow1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Button column in datagrid

    I don't see anything wrong with the code... By any chance, did you set Label5.Visible = False somewhere and forget to turn it back to True?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    334

    Re: Button column in datagrid

    Quote Originally Posted by stanav
    I don't see anything wrong with the code... By any chance, did you set Label5.Visible = False somewhere and forget to turn it back to True?

    Soz for the late reply.... no I do not set the visibility to false no where in the code...still dont know why it doesnt wrk!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    334

    Re: Button column in datagrid

    seems to be an error when creating the column, I "manually" added the row and it all seems to work!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width