473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

pushbutton in datagrid doesn't work

in web form design (C#), I draged a datagrid onto web form, called grdFiles,
and set aotuGenerateColumns property to FALSE. Use the following to populate
data into the datagrid:
// sqlSelectCommand1
this.sqlSelectCommand1.CommandText = "SELECT ID, FileData, FileName,
ContentType, FileSize, UploadDate FROM TestFile";
this.sqlSelectCommand1.Connection = this.dbConn;
//
SqlDataReader myDataReader;
dbConn.Open();
myDataReader = this.sqlSelectCommand1.ExecuteReader();
grdFiles.DataSource = myDataReader;
grdFiles.DataBind();
myDataReader.Close();
dbConn.Close();

//On button event and handller
this.grdFiles.SelectedIndexChanged += new
System.EventHandler(this.grdFiles_SelectedIndexCha nged);
private void grdFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{

lblInfo.Text=System.Convert.ToString(grdFiles.Sele ctedIndex);
txtXML.Text=System.Convert.ToString(grdFiles.Selec tedIndex);
lblInfo.Text += "test event";
}

-----------

I open a web broswer, the data is loaded onto the datagrid and pushbuton in
each row. But when I click the button, there is no message displayed.

Is there anything wrong/missing?

David

Feb 28 '07 #1
1 1580
HTML file for the datagrid:

<asp:DataGrid id="grdFiles" style="Z-INDEX: 104; LEFT: 64px; POSITION:
absolute; TOP: 136px" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="ID"
DataNavigateUrlFormatString="ViewFile.aspx?ID={0}" DataTextField="FileName"
HeaderText="File Name"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="ID" HeaderText="File ID"></asp:BoundColumn>
<asp:BoundColumn DataField="FileSize" HeaderText="File
Size"></asp:BoundColumn>
<asp:BoundColumn DataField="ContentType"
HeaderText="Type"></asp:BoundColumn>
<asp:BoundColumn DataField="UploadDate"
HeaderText="Date"></asp:BoundColumn>
<asp:ButtonColumn Text="show" ButtonType="PushButton"
HeaderText="Display File" CommandName="Select"></asp:ButtonColumn>
</Columns>
</asp:DataGrid>

"david" wrote:
in web form design (C#), I draged a datagrid onto web form, called grdFiles,
and set aotuGenerateColumns property to FALSE. Use the following to populate
data into the datagrid:
// sqlSelectCommand1
this.sqlSelectCommand1.CommandText = "SELECT ID, FileData, FileName,
ContentType, FileSize, UploadDate FROM TestFile";
this.sqlSelectCommand1.Connection = this.dbConn;
//
SqlDataReader myDataReader;
dbConn.Open();
myDataReader = this.sqlSelectCommand1.ExecuteReader();
grdFiles.DataSource = myDataReader;
grdFiles.DataBind();
myDataReader.Close();
dbConn.Close();

//On button event and handller
this.grdFiles.SelectedIndexChanged += new
System.EventHandler(this.grdFiles_SelectedIndexCha nged);
private void grdFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{

lblInfo.Text=System.Convert.ToString(grdFiles.Sele ctedIndex);
txtXML.Text=System.Convert.ToString(grdFiles.Selec tedIndex);
lblInfo.Text += "test event";
}

-----------

I open a web broswer, the data is loaded onto the datagrid and pushbuton in
each row. But when I click the button, there is no message displayed.

Is there anything wrong/missing?

David
Feb 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Maziar Aflatoun | last post by:
Hi everyone, Does anyone know how I can add a CSS (Ex. button1 ) to the following Edit button is ASP .NET? <asp:EditCommandColumn ButtonType="PushButton" EditText="Edit" CancelText="Edit"...
1
by: Mark | last post by:
I have two buttons in a DataGrid. If I leave the ButtonType = "LinkButton", the EditCommand and DeleteCommand events fire fine. If I change th ButtonType = "PushButton", the events do not fire. ...
0
by: Curtis Hatter | last post by:
I apologize if this has been answered, but on the .NET 247 site I saw a thread titled "Datagrid's ItemCommand Event", and had similar troubles with the Datagrid not properly firing the delete event...
2
by: Nick Gilbert | last post by:
We have a Datagrid which contains a template column with a button in it, as well as an actual button column. If either of the buttons are clicked, the ItemCommand event does not fire. If...
6
by: Tim Meagher | last post by:
Can anyone help me figure out how to apply a stylesheet to a pushbutton defined in the asp:BoundColumn or asp:EditCommandColumn elements of a datagrid?
2
by: John Mason | last post by:
Hi, I have a Datagrid control with an edit command column, which has a PushButton ButtonType. I am trying to apply formatting to the plain grey button, to make it look more appealing on...
1
by: serge calderara | last post by:
Dear all, If I used the following code on a datagrid object <Columns> <asp:ButtonColumn Text="Events" ButtonType=LinkButton CommandName="ShowEvent"> </asp:ButtonColumn> </Columns>
0
by: DotQuery | last post by:
Hello ASP.NET team : I have a user control that be added into page at runtime , in a postback event handler . I save the information to view state , and load the user control again in...
1
by: Blasting Cap | last post by:
I am having trouble changing the font for a PushButton control in a datagrid button column. I have seen several posts refer to styles and simple changes to the HTML for font changes but most of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.