0
votes

I have a gridview and I am able to render textboxes, enter value and save it to the database.

  <asp:TemplateField>
     <ItemTemplate>
         <asp:TextBox ID="txtSomething" runat="server" Text='<%# Bind("SOME_COL") %>'></asp:TextBox>
      </ItemTemplate>
      <ItemStyle Width="10%" />
   </asp:TemplateField>
    <asp:TemplateField HeaderStyle-ForeColor="white" 
                       HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="5%">
       <ItemTemplate>
            <asp:LinkButton Id="btnSomething" runat="server" 
                            CommandArgument='<%# Eval("SOME_ID") %>' 
                            CommandName="WaitPeriodSave" CausesValidation="false"
                 >Save</asp:LinkButton>

The command argument is SOME_ID and it might contain value 4, but it might be 2nd row on the gridview.

Can I pass more than one value in command argument? If yes, How? Also, is there a way to determine the selected row number In the above scenario it is 2 which is probably zero based so it should be 1.

1
I do not want this to sound rude, but you have posted 69 questions, and have been a member here for over a year. Please format your code samples better so that others do not have to spend time editing your questions. - jwheron
Jwiscarson - My bad!Going forward I will. Thank you. - kalls

1 Answers

3
votes

CommadArgument is of type string; therefore, if you want to pass more than one argument in the CommandArgument property, you have to come up with some sort of convention to do it, for example, concatenating the arguments and separating them by commas and then split them on the code behind. For example:

CommandArgument='<%# string.Format("{0},{1}",Eval("SOME_ID"),Eval("OTHER_PROPERTY")) %>'