I have a DataGrid:
<asp:datagrid id="articleList" runat="server"
OnDeleteCommand="articleList_DeleteFile"
OnItemDataBound="articleList_ItemDataBound"
DataKeyField="FullName" AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name"
HeaderText="File Name"></asp:HyperLinkColumn>
<asp:TemplateColumn HeaderText="DownLoad">
<ItemTemplate>
<asp:LinkButton id="DownLoad" Text="DownLoad"
OnClick="DownLoad_Click" Runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
HeaderText="Delete" CommandName="Delete"></asp:ButtonColumn>
</Columns>
</asp:datagrid>
I need to get the path and filename of the row selected which is in the
DataKeys fields.
In my Delete button, I find it like so:
public void articleList_DeleteFile(Object sender, DataGridCommandEventArgs
e)
{
//First, get the filename to delete
string fileName = (string)articleList.DataKeys[e.Item.ItemIndex];
But for the link button I can't use e.Item.ItemIndex to find the row number,
so the following doesn't work.
public void DownLoad_Click(Object sender, EventArgs e)
{
//First, get the filename to delete
string fileName = (string)articleList.DataKeys[e.Item.ItemIndex];
I get an error:
'System.EventArgs' does not contain a definition for 'Item'
How do I get the Row number so I can do something like:
string fileName = (string)articleList.DataKeys[ROWNUMBER];
Thanks,
Tom 2 2557
Hi,
You can set the CommandName property of the link button to "Download",
remove the OnCilck handler from the LinkButton and use the DataGridCommand
event handler as follows
public void articleList_ItemCommand(Object sender, DataGridCommandEventArgs
e)
{
if (e.CommandName=="Delete")
{
//delete
}
if (e.CommandName=="Download")
{
//download
}
}
Regards,
Mohamed Mosalem
"tshad" <ts**********@ftsolutions.comwrote in message
news:eI**************@TK2MSFTNGP03.phx.gbl...
>I have a DataGrid:
<asp:datagrid id="articleList" runat="server"
OnDeleteCommand="articleList_DeleteFile"
OnItemDataBound="articleList_ItemDataBound"
DataKeyField="FullName" AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name"
HeaderText="File Name"></asp:HyperLinkColumn>
<asp:TemplateColumn HeaderText="DownLoad">
<ItemTemplate>
<asp:LinkButton id="DownLoad" Text="DownLoad"
OnClick="DownLoad_Click" Runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="Delete" ButtonType="PushButton"
HeaderText="Delete" CommandName="Delete"></asp:ButtonColumn>
</Columns>
</asp:datagrid>
I need to get the path and filename of the row selected which is in the
DataKeys fields.
In my Delete button, I find it like so:
public void articleList_DeleteFile(Object sender, DataGridCommandEventArgs
e)
{
//First, get the filename to delete
string fileName = (string)articleList.DataKeys[e.Item.ItemIndex];
But for the link button I can't use e.Item.ItemIndex to find the row
number, so the following doesn't work.
public void DownLoad_Click(Object sender, EventArgs e)
{
//First, get the filename to delete
string fileName = (string)articleList.DataKeys[e.Item.ItemIndex];
I get an error:
'System.EventArgs' does not contain a definition for 'Item'
How do I get the Row number so I can do something like:
string fileName = (string)articleList.DataKeys[ROWNUMBER];
Thanks,
Tom
That works.
Thanks,
Tom
"Mohamed Mosalem" <mo*************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi,
You can set the CommandName property of the link button to "Download",
remove the OnCilck handler from the LinkButton and use the DataGridCommand
event handler as follows
public void articleList_ItemCommand(Object sender,
DataGridCommandEventArgs e)
{
if (e.CommandName=="Delete")
{
//delete
}
if (e.CommandName=="Download")
{
//download
}
}
Regards,
Mohamed Mosalem
"tshad" <ts**********@ftsolutions.comwrote in message
news:eI**************@TK2MSFTNGP03.phx.gbl...
>>I have a DataGrid:
<asp:datagrid id="articleList" runat="server" OnDeleteCommand="articleList_DeleteFile" OnItemDataBound="articleList_ItemDataBound" DataKeyField="FullName" AutoGenerateColumns="False"> <Columns> <asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name"></asp:HyperLinkColumn> <asp:TemplateColumn HeaderText="DownLoad"> <ItemTemplate> <asp:LinkButton id="DownLoad" Text="DownLoad" OnClick="DownLoad_Click" Runat="server"></asp:LinkButton> </ItemTemplate> </asp:TemplateColumn> <asp:ButtonColumn Text="Delete" ButtonType="PushButton" HeaderText="Delete" CommandName="Delete"></asp:ButtonColumn> </Columns> </asp:datagrid>
I need to get the path and filename of the row selected which is in the DataKeys fields.
In my Delete button, I find it like so:
public void articleList_DeleteFile(Object sender, DataGridCommandEventArgs e) { //First, get the filename to delete string fileName = (string)articleList.DataKeys[e.Item.ItemIndex];
But for the link button I can't use e.Item.ItemIndex to find the row number, so the following doesn't work.
public void DownLoad_Click(Object sender, EventArgs e) { //First, get the filename to delete string fileName = (string)articleList.DataKeys[e.Item.ItemIndex];
I get an error:
'System.EventArgs' does not contain a definition for 'Item'
How do I get the Row number so I can do something like:
string fileName = (string)articleList.DataKeys[ROWNUMBER];
Thanks,
Tom
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Fresh Air Rider |
last post by:
Hello
Could anyone please explain how I can pass more than one
arguement/parameter value to a function using <asp:linkbutton> or is
this a major shortfall of the language ?
Consider the...
|
by: News |
last post by:
Hi,
I need help with datalist and linkbutton. I need a LinkButton to display in
datalist if datafield "is_measure_customchecklist" in a db table set to
true.
Here is the code (in parts):
...
|
by: MRW |
last post by:
I have a simple linkbutton and a function when it's clicked. It works
perfectly in a regular .aspx page. However, when I place it inside the
ContentPlaceHolder, it no longer works. It does...
|
by: rn5a |
last post by:
In a shopping cart app, suppose a user has placed 5 orders, I want to
show him 5 LinkButtons (one for each order) so that when he clicks the
first LinkButton, he would be shown the details of his...
|
by: rn5a |
last post by:
Consider the following code which creates LinkButtons dynamically:
For i = 1 to 5
lnkBut = New LinkButton
lnkBut.ID = "lnkBut" & i
lnkBut.Text = i.ToString & " "
lnkBut.CommandName = i...
|
by: OceanBreeze |
last post by:
I have added a LinkButton to a table cell programmatically inside the Page_Load method. I also added a custom event to that link button. The same custom event is valid for all the link buttons. The...
|
by: =?Utf-8?B?SmFrb2IgTGl0aG5lcg==?= |
last post by:
I have two sets of search criteria on my page.
They are placed inside two DIV tags made visible/hidden by a client script.
In each DIV tag I have a LinkButton that performs the search from each...
|
by: HillBilly |
last post by:
MasterPages again. Three LinkButtons are being used as styled tabs in the
content page that will load a different ListView when a tab is selected:
TabA, TabB or TabC. The LinkButtons are declared...
|
by: Peter Larsen [CPH] |
last post by:
Hi,
The following sample shows a LinkButton in the HeaderTemplate of a Repeater
control.
The problem is that i'm not able to access the linkbutton in code (in the cs
file) as long as the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |