Using a repeater to display a list,(with 'remove' btn beside each record) click 'remove' and it removes from the list. Im passing 'id' using commandArgument, I want to pass another value…'company name' tried it through text, but not sure how to pass it…then in code behind I use companyName to get contractorId, (company name for the contractor
<td>
<asp:LinkButton ID="LinkButton1" CommandArgument='<%# Bind ("id") %>' runat="server" OnCommand="RemoveSubContractor" CssClass="bottomhyperlink">Remove</asp:LinkButton>
<asp:HiddenField id="hdnCompanyName" value='<%#Bind("Company_Name")%>'>
</td>
In code behind:
HiddenField hdnCompanyName = (HiddenField)e.CommandArgument.ToString("hdnCompanyName);
string companyName = hdnCompanyName.Value;
Then problem is coming from code behind after the e.commandArgument I tried to do .findControl but it wouldnt allow me…ANyone know what I am missing? thank you
Best Answer
You can loop through the repeater items, get the item with the id passed through by
CommandArgument='<%# Bind ("id") %>'
and callFindControl()
to get the company name, here's an example:ASPX:
Code behind:
Perhaps even a better solution would be to pass both id and company name to the
CommandArgument
this will avoid extra processing created by looping through the repeater:ASPX:
Code behind:
Just split the string and there are both your parameters!