|
-
Mar 4th, 2002, 04:25 PM
#1
Thread Starter
Member
DataGrid in ASP.net
What event get triggered when the select button is clicked in the Data Grid server control.
Thanks in advance!!!!!!!
Everyone!!! Can I have your attention please?
Sit back, Relax and watch the world unfold before your very eyes.
Mystical isn't it, oh well I tried!!!
-
Mar 4th, 2002, 04:34 PM
#2
what 'select' button? There nothing called a select button.
Are you referring to a hyperlinkcolumn, buttoncolumn, template column, editcolumn???
-
Mar 4th, 2002, 04:45 PM
#3
Thread Starter
Member
ButtonColumn Type=PushButton Name=Select Text=Add
Everyone!!! Can I have your attention please?
Sit back, Relax and watch the world unfold before your very eyes.
Mystical isn't it, oh well I tried!!!
-
Mar 4th, 2002, 05:26 PM
#4
ok..its just named select..got ya..here you go
first add this attribute to the datagrid tag
OnItemCommand="Grid_Command"
Grid_Command is the name of the called Sub..you can name it anything else...your choice
add this attribute to your button tag
CommandName="Select"
NMow here is the sub
Code:
Sub Grid_Command(sender As Object, e As DataGridCommandEventArgs)
If e.CommandSource.CommandName = "Select" Then
'Do something
End If
End Sub
-
Mar 5th, 2002, 08:28 AM
#5
Thread Starter
Member
I did that it doesn't do anything. I put a break on the if statement and attempted to click on the button. The application never reaches that sub.
Everyone!!! Can I have your attention please?
Sit back, Relax and watch the world unfold before your very eyes.
Mystical isn't it, oh well I tried!!!
-
Mar 5th, 2002, 09:17 AM
#6
can you post your page's code here so I can see..maybe be some minor little thing?
-
Mar 5th, 2002, 09:45 AM
#7
Thread Starter
Member
Here is code in the aspx file:
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 46px; POSITION: absolute; TOP: 90px" runat="server" CellPadding="3" BackColor="#DEBA84" BorderWidth="1px" CellSpacing="2" BorderStyle="None" BorderColor="#DEBA84" AllowPaging="True" PageSize="5" Height="147px" Width="603px" OnItemCommand="DataGrid1_Select" AutoGenerateColumns="False">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C"></SelectedItemStyle>
<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#A55129"></HeaderStyle>
<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
<Columns>
<asp:ButtonColumn Text="Add" ButtonType="PushButton" HeaderText="Select Report" CommandName="Select" />
<asp:BoundColumn HeaderText="Report ID" DataField="ReportID" />
<asp:BoundColumn HeaderText="Title" DataField="Title" />
<asp:BoundColumn HeaderText="Pages" DataField="Pages" />
<asp:BoundColumn HeaderText="Lines" DataField="Lines" />
<asp:BoundColumn HeaderText="Time" DataField="Time" />
<asp:BoundColumn HeaderText="Date" DataField="Date" />
<asp:BoundColumn HeaderText="Status" DataField="Status" />
<asp:BoundColumn HeaderText="PartitionNum" DataField="PartitionNum" />
<asp:BoundColumn HeaderText="CorpCode" DataField="CorpCode" />
<asp:BoundColumn HeaderText="SubsdCompCode" DataField="SubsdCompCode" />
<asp:BoundColumn HeaderText="OperDivCode" DataField="OperDivCode" />
<asp:BoundColumn HeaderText="StoreDivCode" DataField="StoreDivCode" />
<asp:BoundColumn HeaderText="StoreLeagueCode" DataField="StoreLeagueCode" />
<asp:BoundColumn HeaderText="StoreNum" DataField="StoreNum" />
</Columns>
<PagerStyle HorizontalAlign="Left" ForeColor="#8C4510" PageButtonCount="5" Mode="NumericPages"></PagerStyle>
</asp:datagrid><asp:listbox id="ListBox1" style="Z-INDEX: 102; LEFT: 5px; POSITION: absolute; TOP: 7px" runat="server" Height="72px" Width="390px"></asp:listbox></form>
</body>
Here is the code in the vb file:
Imports System.Data
Public Class WebForm1
Inherits System.Web.UI.Page
Dim DS As New DataSet()
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
Protected WithEvents ListBox1 As System.Web.UI.WebControls.ListBox
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim A As Integer
DS.ReadXml("D:\Inetpub\WWWRoot\DatarGrid1\GetReports.xml")
Dim Source As DataView
Source = New DataView(DS.Tables(0))
Me.DataGrid1.DataSource = Source
Page.DataBind()
For A = 8 To 14
Me.DataGrid1.Columns(A).Visible = False
Next
End Sub
Private Sub ChangeGridPage(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
Page.DataBind()
End Sub
Public Sub DataGrid1_Select(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
If e.CommandSource.CommandName = "Select" Then
Me.ListBox1.Items.Add("I finally selected a line")
End If
End Sub
End Class
Thanks for you assistance
Everyone!!! Can I have your attention please?
Sit back, Relax and watch the world unfold before your very eyes.
Mystical isn't it, oh well I tried!!!
-
Mar 5th, 2002, 09:51 AM
#8
Are any of your procedures being run? I dont see this line specifying what .vb file and class to use with your aspx page for code behind
<%@ Page language="vb" Inherits="WebForm1" SRC="test.vb"%>
that should be at the very top of your aspx page if you dont have it already.
Everything else looks correct so far.
-
Mar 5th, 2002, 10:55 AM
#9
Thread Starter
Member
Hey that did it!
I guess there is a bug in the pushbutton. I thought about changing it but never did.
Thanks for your help! I'll try to find a way to report this to MS
Everyone!!! Can I have your attention please?
Sit back, Relax and watch the world unfold before your very eyes.
Mystical isn't it, oh well I tried!!!
-
Mar 5th, 2002, 11:00 AM
#10
w00t!
Well you know in after thought..it could be that when using the pushbutton style you may need the On_Click="functiontocall" attribute like with nroaml buttons. Try that too perhaps that is the correct way to do?!?!!?
-
Mar 5th, 2002, 11:07 AM
#11
Thread Starter
Member
I just tried that also but no luck. There is no on_click event for the data grid available only onitemcommand.
thanks for your help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Everyone!!! Can I have your attention please?
Sit back, Relax and watch the world unfold before your very eyes.
Mystical isn't it, oh well I tried!!!
-
Mar 5th, 2002, 11:09 AM
#12
I meant for the actual buttoncolumn tag. Did you try that ?:
-
Mar 5th, 2002, 11:12 AM
#13
Thread Starter
Member
Yeah, it isn't available for that either.
Everyone!!! Can I have your attention please?
Sit back, Relax and watch the world unfold before your very eyes.
Mystical isn't it, oh well I tried!!!
-
Mar 5th, 2002, 11:14 AM
#14
well doo doo!
Oh well..at least it works the other way..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|