GridView 自定义列,删除时给出提示:如 “ 确信要删 除 - 张三 - 吗? ” ,其中张三为当前行的姓名
来源:互联网 发布:湖北网络广播电视 编辑:程序博客网 时间:2024/05/01 03:38
前台:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:studentConnectionString %>"
DeleteCommand="DELETE FROM [student] WHERE [sid] = @sid"
InsertCommand="INSERT INTO [student] ([sname], [classid], [sex], [age], [isking], [photo]) VALUES (@sname, @classid, @sex, @age, @isking, @photo)"
SelectCommand="SELECT * FROM [student]"
UpdateCommand="UPDATE [student] SET [sname] = @sname, [classid] = @classid, [sex] = @sex, [age] = @age, [isking] = @isking, [photo] = @photo WHERE [sid] = @sid">
<DeleteParameters>
<asp:Parameter Name="sid" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="sname" Type="String" />
<asp:Parameter Name="classid" Type="Int32" />
<asp:Parameter Name="sex" Type="String" />
<asp:Parameter Name="age" Type="Byte" />
<asp:Parameter Name="isking" Type="Boolean" />
<asp:Parameter Name="photo" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="sname" Type="String" />
<asp:Parameter Name="classid" Type="Int32" />
<asp:Parameter Name="sex" Type="String" />
<asp:Parameter Name="age" Type="Byte" />
<asp:Parameter Name="isking" Type="Boolean" />
<asp:Parameter Name="photo" Type="String" />
<asp:Parameter Name="sid" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="sid"
DataSourceID="SqlDataSource1" onrowcommand="GridView1_RowCommand"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="sid" HeaderText="编号" InsertVisible="False"
ReadOnly="True" SortExpression="sid" />
<asp:HyperLinkField DataNavigateUrlFields="photo"
DataNavigateUrlFormatString="viewPhoto.aspx?photourl={0}" DataTextField="sname"
HeaderText="姓名" Target="_blank" />
<asp:BoundField DataField="sex" HeaderText="性别" SortExpression="sex" />
<asp:BoundField DataField="age" HeaderText="年龄" SortExpression="age" />
<asp:CheckBoxField DataField="isking" HeaderText="班长" SortExpression="isking" />
<asp:TemplateField HeaderText="照片">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("photo") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<br />
<table style="width:100%;">
<tr><td><a href='viewPhoto.aspx?photourl=<%#Eval("photo") %>'>姓名:<%#Eval("sname") %></a> </td><td> </td><td> </td></tr>
<tr>
<td> </td>
<td> <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("photo") %>' Width="60px" Height="60px" ToolTip='<%#"这是:"+Eval("sname") %>' /> </td>
<td> </td>
</tr>
<tr>
<td>编号:<%#Eval("sid") %> </td>
<td>年龄:<%#Eval("age") %> </td>
<td> </td>
</tr>
</table>
</ItemTemplate>
<ControlStyle Height="60px" Width="60px" />
</asp:TemplateField>
<asp:ButtonField CommandName="delete" HeaderText="删除" Text="删除" />
<asp:ButtonField CommandName="initialPassword" HeaderText="初始化密码"
Text="初始化密码" />
</Columns>
<EmptyDataTemplate>
<table style="width:100%;">
<tr>
<td><a href='viewPhoto.aspx?photourl=<%#Eval("Eval") %>' target="_blank">姓名:<%#Eval("sname") %></a> </td>
</tr>
<tr>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("photo") %>' Width="60px" Height="60px" ToolTip='<%#"这是:"+Eval("sname") %>' />
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
后台:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "initialPassword")
{
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.DataRow)
{
return;
}
string sid = e.Row.Cells[0].Text;
HyperLink link = e.Row.Cells[1].Controls[0] as HyperLink;
LinkButton lbtn = e.Row.Cells[6].Controls[0] as LinkButton;
if (lbtn != null)
{
lbtn.Attributes.Add("onclick", "return confirm('确定要删除编号为:"+sid+"的"+link.Text+"吗?')");
}
}
viewPhoto.aspx前台:
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" />
</div>
</form>
</body>
viewPhoto.aspx后台:
protected void Page_Load(object sender, EventArgs e)
{
this.Image1.ImageUrl = Request["photourl"];
}
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:studentConnectionString %>"
DeleteCommand="DELETE FROM [student] WHERE [sid] = @sid"
InsertCommand="INSERT INTO [student] ([sname], [classid], [sex], [age], [isking], [photo]) VALUES (@sname, @classid, @sex, @age, @isking, @photo)"
SelectCommand="SELECT * FROM [student]"
UpdateCommand="UPDATE [student] SET [sname] = @sname, [classid] = @classid, [sex] = @sex, [age] = @age, [isking] = @isking, [photo] = @photo WHERE [sid] = @sid">
<DeleteParameters>
<asp:Parameter Name="sid" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="sname" Type="String" />
<asp:Parameter Name="classid" Type="Int32" />
<asp:Parameter Name="sex" Type="String" />
<asp:Parameter Name="age" Type="Byte" />
<asp:Parameter Name="isking" Type="Boolean" />
<asp:Parameter Name="photo" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="sname" Type="String" />
<asp:Parameter Name="classid" Type="Int32" />
<asp:Parameter Name="sex" Type="String" />
<asp:Parameter Name="age" Type="Byte" />
<asp:Parameter Name="isking" Type="Boolean" />
<asp:Parameter Name="photo" Type="String" />
<asp:Parameter Name="sid" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="sid"
DataSourceID="SqlDataSource1" onrowcommand="GridView1_RowCommand"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="sid" HeaderText="编号" InsertVisible="False"
ReadOnly="True" SortExpression="sid" />
<asp:HyperLinkField DataNavigateUrlFields="photo"
DataNavigateUrlFormatString="viewPhoto.aspx?photourl={0}" DataTextField="sname"
HeaderText="姓名" Target="_blank" />
<asp:BoundField DataField="sex" HeaderText="性别" SortExpression="sex" />
<asp:BoundField DataField="age" HeaderText="年龄" SortExpression="age" />
<asp:CheckBoxField DataField="isking" HeaderText="班长" SortExpression="isking" />
<asp:TemplateField HeaderText="照片">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("photo") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<br />
<table style="width:100%;">
<tr><td><a href='viewPhoto.aspx?photourl=<%#Eval("photo") %>'>姓名:<%#Eval("sname") %></a> </td><td> </td><td> </td></tr>
<tr>
<td> </td>
<td> <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("photo") %>' Width="60px" Height="60px" ToolTip='<%#"这是:"+Eval("sname") %>' /> </td>
<td> </td>
</tr>
<tr>
<td>编号:<%#Eval("sid") %> </td>
<td>年龄:<%#Eval("age") %> </td>
<td> </td>
</tr>
</table>
</ItemTemplate>
<ControlStyle Height="60px" Width="60px" />
</asp:TemplateField>
<asp:ButtonField CommandName="delete" HeaderText="删除" Text="删除" />
<asp:ButtonField CommandName="initialPassword" HeaderText="初始化密码"
Text="初始化密码" />
</Columns>
<EmptyDataTemplate>
<table style="width:100%;">
<tr>
<td><a href='viewPhoto.aspx?photourl=<%#Eval("Eval") %>' target="_blank">姓名:<%#Eval("sname") %></a> </td>
</tr>
<tr>
<td>
<asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("photo") %>' Width="60px" Height="60px" ToolTip='<%#"这是:"+Eval("sname") %>' />
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:GridView>
后台:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "initialPassword")
{
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.DataRow)
{
return;
}
string sid = e.Row.Cells[0].Text;
HyperLink link = e.Row.Cells[1].Controls[0] as HyperLink;
LinkButton lbtn = e.Row.Cells[6].Controls[0] as LinkButton;
if (lbtn != null)
{
lbtn.Attributes.Add("onclick", "return confirm('确定要删除编号为:"+sid+"的"+link.Text+"吗?')");
}
}
viewPhoto.aspx前台:
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" />
</div>
</form>
</body>
viewPhoto.aspx后台:
protected void Page_Load(object sender, EventArgs e)
{
this.Image1.ImageUrl = Request["photourl"];
}
- GridView 自定义列,删除时给出提示:如 “ 确信要删 除 - 张三 - 吗? ” ,其中张三为当前行的姓名
- GridView 自定义列,删除时给出提示:如 “ 确信要删 除 - 张三 - 吗? ” ,其中张三为当前行的姓名
- GridView 自定义列,删除时给出提示:如 “ 确信要删 除 - 张三 - 吗? ” ,其中张三为当前行的姓名
- 1 使用自定义列显示班级学生信息,要求能够进 行删除和修改,删除时给出提示:如 “ 确信要删 除 - 张三 - 吗? ” ,其中张三为当前行的姓名
- 使用自定义列显示班级学生信息,要求能够进 行删除和修改,删除时给出提示:如 “ 确信要删 除 - 张三 - 吗? ” ,其中张三为当前行的姓名
- 创建数据库,库名为考生姓名拼音的缩写,例如考生姓名为张三
- 如何用JSON数据来表示“张三的颜值很高”?
- 人生的三张财务报表
- 为gridview里的删除列添加删除时确认提示
- loner_li 机试题 一个文本文件含有如下内容,分别表示姓名和成绩:张三 90 ..提供用户一个控制台界面,允许用户输入要查询的姓名,输入姓名并且按回车以后,打印出此人的成绩...
- 值得中国人深思的三张图片
- 向伟大的张三同志致敬
- 《汉武帝的三张面孔》 姜鹏
- 张三,李四的数据题
- 图片(多张)横向滚动,当鼠标停放在其中一张图片时,此张图片发大,滚动停。
- GridView模板列中的TextBox的ontextchanged事件中获取当前行的某列
- GridView模板列中的TextBox的ontextchanged事件中获取当前行的某列!
- 自定义viewpager 三张图片在同一屏幕轮播的效果
- 在Linux上开发网络服务器的一些相关细节:poll与epoll
- 有一段时间没写博客了
- oracle,scott帐户解锁
- 黑马程序员之C#学习笔记:C#中页面之间传值传参的六种方法
- javaScript编码解码
- GridView 自定义列,删除时给出提示:如 “ 确信要删 除 - 张三 - 吗? ” ,其中张三为当前行的姓名
- 写给菜鸟My的Java基础
- 马克斯采集土豆视频失败的解决办法:曲线采集
- CSS的position与float的问题
- ActiveMQ入门
- epoll使用(2)-- 奇怪的异步使用方式
- javascript中的编码与解码
- C#获取 Flv视频文件播放时间长度等信息
- Android_Menifest文件相关