Question about Datagrid

G

Guest

Hi,

I have form with datagrid. This is what my form tag looks like,

<form runat="server">
<asp:label runat="server" id="lblMessage" />
<asp:DataGrid runat="server" id="articleList"
DataKeyField="FullName"
OnItemDataBound="articleList_ItemDataBound"
OnEditCommand = "articleList_Edit"
OnCancelCommand = "articleList_Cancel"
OnUpdateCommand = "articleList_Update"
OnDeleteCommand="articleList_DeleteFile"
OnItemCommand="articleList_DownloadFile">
<Columns>
<asp:EditCommandColumn
ButtonType="PushButton"
HeaderText = ""
EditText = "Rename"
CancelText = "Cancel"
UpdateText = "Update" />
<asp:ButtonColumn Text="Delete" ButtonType="PushButton" HeaderText=""
CommandName="Delete" />
<asp:ButtonColumn Text="Download" ButtonType="PushButton" HeaderText=""
CommandName="Download" />
<asp:BoundColumn DataField="Name" HeaderText="File Name" />
<asp:BoundColumn DataField="LastWriteTime" DataFormatString="{0:d}"
HeaderText="Last Write Time" ReadOnly="true"
runat="server" />
<asp:BoundColumn DataField="Length" DataFormatString="{0:#,### bytes}"
HeaderText="File Size" ReadOnly="true"
runat="server" />
</Columns>
</asp:DataGrid>
</form>


The Edit and Delete buttons work the moment I take out the following two
lines,
OnItemCommand="articleList_DownloadFile"

And

<asp:ButtonColumn Text="Download" ButtonType="PushButton" HeaderText=""
CommandName="Download" />

It appears that when the above lines are part of the form, when I click the
Edit button, the control doesn't even go in the event handler
articleList_Edit.

Can someone give me some idea as what could be wrong here? Is somthing wrong
with my form tag? Is it beacsue OnItemDataBound, OnEditCommand,
OnCancelCommand, OnUpdateCommand, OnDeleteCommand and OnItemCommand don't
work if together?

Thanks in advance for your time and help.

Green
 
Y

Yunus Emre ALPÖZEN [MCSD.NET]

Hi,
EditCommand, DeleteCommand, SelectCommand, CancelCommand, and UpdateCommand
all of these commands are ItemCommands. It is expected behaviour to raise
ItemCommand every time..

So What should u do? In your case u should check CommandName whether it is
"Download". CommandName can be accessible via argument parameter.

--
HTH

Thanks,
Yunus Emre ALPÖZEN
BSc, MCSD.NET
 

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,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top