views:

307

answers:

1

Gridview has many columns and a Delete button as well. Delete button is a control as TemplateField

<asp:TemplateField>
 <ItemTemplate>
  <asp:LinkButton ID="btnDelete" CommandName="Delete" Text='<%#     Eval("disabled").ToString()=="False" ? "Disabled" : "Enabled" %>'
 OnClientClick="return confirm('Are you sure you want to take this action?');"
 runat="server"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

Now associated SQLDataSource's Delete command's stored procedure is expecting two parameters. One is going from DataKeyNames (RowID), other one i wanna pass is the Text of btnDelete (True or False).

How can i achieve it?

A: 

I would recommend doing it in the code behind. On btnDelete click i would iterate through every row in your gridview and check all the datakeynames. Once i found the one you want to delete you will need to send that back to you db. You can use either an orm like linq, ado.net, or a straight sqlcmd.

george9170