<asp:GridView ID="grdview" runat="server" AutoGenerateColumns="false" OnRowCommand="grdview_RowCommand">
<Columns>
<asp:BoundField ReadOnly="True" HeaderText="sno" InsertVisible="False" DataField="sno"
SortExpression="sno"></asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CommandArgument='<%#Eval("site")%>'
Text='<%#Eval("site")%>' CommandName='site' CausesValidation="False"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected
ASPX.CS
void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from newtable", con);
SqlDataAdapter dtAdapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
dtAdapter.Fill(ds);
con.Close();
grdview.DataSource = ds.Tables[0];
grdview.DataBind();
}
}
protected void grdview_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "site")
{
string url = "http://" + e.CommandArgument.ToString();
Response.Write("<script>window.open('" + url + "' );</script>");
}
}