473,326 Members | 2,126 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,326 software developers and data experts.

Question about Datagrid

Joe
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

Nov 19 '05 #1
1 1305
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

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
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

Nov 19 '05 #2

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

Similar topics

5
by: AC | last post by:
Any reason i'm having trouble with: DataGrid1.Columns(7).ItemStyle.HorizontalAlign = HorizontalAlign.Right I'm trying to directly set the column alignment of a datagrid created at runtime.. ...
1
by: Moshfegh Hamedani | last post by:
Hi there, I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but...
0
by: Moshfegh Hamedani | last post by:
Hi there, I found this question in Amit Kalani's preparation book for exam 70-15 (Developing Web Applications with C#). I think it's a very stupid question! It says the correct answer is A but...
5
by: Manny Chohan | last post by:
i have the following situatin: In datagrid i click on hyperlink button to navigate to the detail.aspx page which displays detailed information regarding item id passed from datagrid. Can i put...
6
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP...
0
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box...
0
by: | last post by:
Greets All, Question on data in datagrid /listbox and looping? I’m trying to decide the best way to write this code. 1 would like the user to make several selections from one listbox/combo box...
2
by: JohnR | last post by:
I have a question on bindingcontext, bindings, and controlbindingscollection. I understand the very basic idea, and I think I should be able to do this, but I'm not sure how. First problem: I...
1
by: amber | last post by:
I have a form, with multiple tabs. Each tab contains 1 datagrid except for the last tab which contains 2 datagrids. I have a toolbar that I use for the entire form. When the 'delete' button is...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.