T
tshad
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
<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