pushbutton in datagrid doesn't work

G

Guest

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_SelectedIndexChanged);
private void grdFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{

lblInfo.Text=System.Convert.ToString(grdFiles.SelectedIndex);
txtXML.Text=System.Convert.ToString(grdFiles.SelectedIndex);
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
 
G

Guest

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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top