Developing In: c# asp.net web forms 4.5
I've looked at many posts and all of them made a hyperlink with either datafield in it, by datatextfield() or similar.. or called eval from backend. I didn't do neither of that, so I tried doing every thing I could but it didn't work. CommandField, HyperLinkeField, HyperLink, .. all didn't work.
The main point is that the data comes out fine, but I can't seem to make it hyperlink. Is it impossible to have a hyperlink this way?
I'm trying to make a hyperlink on gridview. The thing is that the column I'm trying to make the hyperlink doesn't get data from the datafield.
It gets it by onRowDataBound method of gridview something like this..
<asp:GridView runat="server" ID="someGrid" CellPadding="10"
DataKeyNames="idx" AutoGenerateColumns="false"
selectMethod="someGrid_GetData" ItemType="someTable"
updateMethod="someGrid_UpdateItem" AutoGenerateEditButton="true"
deleteMethod="someGrid_DeleteItem" AutoGenerateDeleteButton="true"
onRowDataBound="someGrid_RowDataBound">
<Columns>
<asp:BoundField DataField="thing1" HeaderText="thing1" />
<asp:BoundField DataField="thing2" HeaderText="thing2"/>
<asp:DynamicField DataField="poDate" DataFormatString="{0:d}" />
<asp:BoundField HeaderText="vendor" />
<asp:CommandField HeaderText="sku" ShowSelectButton="true" SelectText="{0}" ButtonType="Link"/>
</Columns>
</asp:GridView>
and on the code background, it goes like this..
protected void soGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
using (soAction soa = new soAction())
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string s = e.Row.Cells[2].Text;
string thin1 = soa.get_thin1(s);
e.Row.Cells[4].Text = thin1;
string thin2 = soa.get_thin2(s);
e.Row.Cells[5].Text = thin2;
}
}
}
Thanks!
edit : Maybe I wasn't clear about what is the challenge here.. normally the examples use dataTextField property in gridview but I cannot use the dataTextField property because I'm binding the data depending on the model rendered afterwards. I'm doing this because I wanted to set the itemType into someTable so I can use the updatemethod and deleteMethod of the asp.net.