2

I have a TemplateField column in a gridview with a image button inside of it. i need to use two command arguments within single image button. here is my code

<asp:TemplateField ItemStyle-Width="30px">
     <ItemTemplate>
         <asp:ImageButton ID="btnAvaililabitly" runat="server" 
                          ImageUrl="~/CMS/images/available_icon.png"
                          Width="12px" Height="12px" CommandName="availability" 
                          ToolTip="Rooms Availability"
                          CommandArgument='<%#Eval("HotelID")%>'/>
     </ItemTemplate>
</asp:TemplateField>

please help

3
  • Why? Do you have a key for the table that you list here? Then use that. However,you can use a separator(e.g. comma) and split it on serverside. Commented Mar 21, 2013 at 11:52
  • I formatted your markup to make it neat and tidy. Commented Mar 21, 2013 at 11:57
  • possible duplicate of Passing multiple argument through CommandArgument of Button in Asp.net Commented Mar 21, 2013 at 11:59

1 Answer 1

5

You can send comma separated string and collect value on server side

CommandArgument= '<%# String.Format("{0} , {1}", Eval("Name1"), Eval("Name2")) %>'
Sign up to request clarification or add additional context in comments.

3 Comments

i got error after applying that "Server Tag not well formed " <asp:ImageButton ID="ibtnEdit" runat="server" ImageUrl="~/CMS/images/edit_icon.png" Width="12px" Height="12px" CommandName="edit" ToolTip="Edit" CommandArgument='<%#Eval("HotelID")%>','<%#Eval("IsSpanish")%>' />
Try this, '<%#Eval("HotelID")%>,<%#Eval("SccondColumn")%>'
this shows another error "Preprocessor directives must appear as the first non-whitespace character on a line "

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.