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! :sick:
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
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?
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!
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! :)