I am using the Invoice Id number as a Hyperlink in the gridview ItemTemplate column. I need to get that number when the user checks the checkbox of that row. Problem getting the value of that Hyperlink, which is the invoice id, that I need to complete the C# code. I not understanding how to get the value of the Hyperlink control. I see the code will get me the control itself, but no idea how to get the value of the control.
for (int i = 0; i < gv_ebill.Rows.Count; i++)
GridViewRow row = gv_ebill.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("ck_ebill")).Checked;
// trying to get the invoiceid from the row
int invoiceid = row.FindControl("invoiceId").
invoice = new Invoice(Convert.ToInt32(row.Cells.Text), currentClient.Practice.Id);
<asp:TemplateField HeaderText = "Id" SortExpression="id">
ID="invoiceId" runat="server" NavigateUrl='~/Invoice_Overview.aspx?Id=<%# Eval("Id") %>' ><%# Eval("Id") %></asp:HyperLink>
Not sure what you mean by value.
You can get a reference to the control like this
then you can use hl to get different aspects of it.
I have a column with Invoice Id's like '99009' and it is a hyperlink to let the user look at the invoice. But I need to get the '99009' into my C# code to use it in the program. I can't detect how to get the Hyperlink value as an Int in C#.
As wwb said. You need to parse / convert your hyperlinks text value into and int. Like he suggested above or using Convert.ToInt32(string value);