Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 27th, 2003, 10:37 AM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Buttoncolums in a Datagrid

Hi all,
i have seruoius problems adding a buttoncolum to a datagrid programmatically.
I added a buttoncolum to the datagrid whitc simply selects the item. At this point i would like have fired the SelectedIndex-Event, but nothing happened !!!


This is my code:

Private Sub Page_Load (...

[omitted]

        DataGrid1.DataSource = myDs
        DataGrid1.DataMember = myDs.Tables(0).TableName.ToString

        Dim colonna As New ButtonColumn()
        colonna.ButtonType = ButtonColumnType.LinkButton
        colonna.HeaderText = "Select"
        colonna.Text = "Select"
        colonna.CommandName = DataGrid1.SelectCommandName
        colonna.DataTextField = myDs.Tables(0).Columns(0).ColumnName.ToString
        colonna.DataTextFormatString = "Sel"

        DataGrid1.Columns.AddAt(myDs.Tables(0).Columns.Cou nt, colonna)

        DataGrid1.DataBind()

[omitted]

End Sub

Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
        Errlabel.Text = sender.SelectedItem.Cells.Item(0).Text
End Sub


Can anyone help me, please????

  #2 (permalink)  
Old August 27th, 2003, 11:27 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Is it necessary to bind the data every time the page loads? You really should only call the binding code when "Not IsPostBack". This might be what's causing the problem.

Peter


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom paging in Datagrid with datagrid page count madhusrp ASP.NET 1.0 and 1.1 Professional 12 June 2nd, 2008 01:15 PM
Datagrid asters Pro VB.NET 2002/2003 2 October 18th, 2007 07:43 AM
User COntrol Datagrid inside datagrid rodmcleay ASP.NET 1.0 and 1.1 Professional 3 April 14th, 2007 10:11 AM
Creating DataGrid In Repeater/DataGrid liduwan ASP.NET 1.0 and 1.1 Professional 9 March 6th, 2007 03:31 PM
Help with Datagrid schindle ASP.NET 1.x and 2.0 Application Design 1 October 15th, 2004 01:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.