source:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" DataKeyNames="eid"
onrowcommand="GridView1_RowCommand" AutoGenerateColumns="False"
CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:TemplateField HeaderText="edit">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" ImageUrl='<%#Eval("path") %>' runat="server"
Height="48px" Width="39px" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="eid" />
<asp:BoundField DataField="ename" />
<asp:BoundField DataField="ejob" />
<asp:BoundField DataField="esal" />
</Columns>
</asp:GridView>
</div>
</form>
C# code:
SqlConnection cn = new SqlConnection("server=.;uid=sa;pwd=sa123;database=empdb");
SqlDataAdapter da;
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gv();
}
}
void gv()
{
da = new SqlDataAdapter("select * from path ", cn);
ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
}
No comments:
Post a Comment