This is a migrated thread and some comments may be shown as answers.

commandargument to hole database value

1 Answer 27 Views
Grid
This is a migrated thread and some comments may be shown as answers.
kyle goodfriend
Top achievements
Rank 2
kyle goodfriend asked on 22 Jul 2010, 04:11 AM
How do I get the commandargument to hold the datatextfield value.  If I remove the datatextformatstring, the column shows the value for ID.  I want to pass the ID value as the argument.  Below produces an argument of {0}.

<telerik:GridButtonColumn CommandArgument="{0}" CommandName="SendEmail"
    ConfirmText="Do you want to send an email to all residents about this service?"
    DataTextField="ID" DataTextFormatString="Send Email" Text="SendEmail"
    UniqueName="column2">
</telerik:GridButtonColumn>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Jul 2010, 08:05 AM
Hello,


You can access the DataKeyValue in the code behind without using CommandArgument. See the code snippet shown below.

CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
 {
     if (e.CommandName == "SendEmail")
     {
         string id = (e.Item as GridDataItem).GetDataKeyValue("ID").ToString();
         Response.Write(id);
     }
 }


Hope it helps. :)

-Shinu.
Tags
Grid
Asked by
kyle goodfriend
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or