Re: gridview help

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks Suresh. that worked.

"Suresh" <Suresh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:15FC4387-239A-4C38-B565-CEE869C6424F@xxxxxxxxxxxxxxxx
I believe using the CommandArgument to determine the row index only works
when you use the command field in a gridview.

Not sure if row index is what you are after in the CommandArgument??
If it is try the following:

(FYI you can bind any data item value to the commandargument property as
well)

asp:LinkButton ID="btnedit" runat="server" Text='<%#Eval("feeid") %>'
CommandName="EditSelect" CommandArgument="<%# Container.DataItemIndex %>"
/>

HTH,
Suresh.

"param@xxxxxxxxxxxxxxxx" wrote:

Hi all,

I am trying to have a linkbutton control with the commandname property
set.
However, when I invoke it, the CommandArgument property ends up coming to
be
blank. However, if I click on the buttonfield control i get back the
rowindex in CommandArgument. Why is that? How do I get my custom
linkbutton
to work?

public void GridView_Command(object sender, GridViewCommandEventArgs e)

{

switch (e.CommandName)

{

case "EditSelect":

Response.Write(e.CommandArgument);

Response.End();

GridView_Edit(Convert.ToInt32(e.CommandArgument));

break;

}

}

<asp:ButtonField ButtonType="Link" CommandName="EditSelect"
HeaderText="ID"
Text="Edit" />

<asp:TemplateField HeaderText="ID" HeaderStyle-HorizontalAlign="left"
ItemStyle-HorizontalAlign="left">

<ItemTemplate>

<asp:LinkButton ID="btnedit" runat="server" Text='<%#Eval("feeid") %>'
CommandName="EditSelect" />

</ItemTemplate>

</asp:TemplateField>



TIA!





.


Quantcast