/// <summary>
/// 生成事件时激发
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void DVClientInfo_RowCommand(object sender, GridViewCommandEventArgs e)
{
//int strProjectId = Convert.ToInt32(e.Item.Cells[0].Text);
int strProjectId = 0; GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
int index = gvrow.RowIndex;
string id = DVClientInfo.Rows[index].Cells[1].Text.ToString(); if (e.CommandName == "redact")//编辑
{
}
else if (e.CommandName == "forbid")//禁用
{
bool temp = centaline.Pro.ClassLibrary.Property.CProject.UpStatusF(strProjectId);
}
else if (e.CommandName == "comeback")//恢复
{
bool temp = centaline.Pro.ClassLibrary.Property.CProject.UpStatusR(strProjectId);
}
}
<asp:GridView ID="DVClientInfo" runat="server"onrowdatabound="DVClientInfo_RowDataBound" onrowcommand="DVClientInfo_RowCommand">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input id="Checkbox2" type="checkbox" runat="server" /><label>全选</label>
</HeaderTemplate>
<Headerstyle ForeColor="#333333" Height="24px" Width="60Px" Wrap="False" />
<Itemstyle HorizontalAlign="Center" Height="24px" />
</asp:TemplateField>
<asp:BoundField Visible="False" DataField="ProjectId" HeaderText="ProjectId">
</asp:BoundField>
<asp:BoundField DataField="ProjectName" HeaderText="项目名称" >
</asp:BoundField>
<asp:BoundField DataField="ProjectCode" HeaderText="项目编号" >
</asp:BoundField>
<asp:BoundField DataField="orgName" HeaderText="隶属部门" >
</asp:BoundField>
<asp:BoundField DataField="Status" HeaderText="状态" >
</asp:BoundField>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:LinkButton ID="lbtn_redact" runat="server" CommandName="redact" ForeColor="#0099FF">编辑</asp:LinkButton>
<asp:LinkButton ID="lbtn_forbid" runat="server" CommandName="forbid" ForeColor="#0099FF">禁用</asp:LinkButton>
<asp:LinkButton ID="lbtn_comeback" runat="server" CommandName="comeback" ForeColor="#0099FF">恢复</asp:LinkButton>
</ItemTemplate>
<Itemstyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
</asp:GridView>
我要把<asp:BoundField Visible="False" DataField="ProjectId" HeaderText="ProjectId"></asp:BoundField>中的Visible="False"去掉后台id才能取到值!可是这个列又不能显示出来!高手能帮忙解决一下吗?
解决方案 »
- 表单提交到另外一个网页时,如何取得前一页面的HttpInputFile
- VB.NET做的网页修改时,如果内容中有一些敏感字符,如:单引号,或其它符号或字母子,则保存失败!
- |M| 今天看了别人写的一个SqlHelper 大家看看这里是什么意思
- 为什么 上传图片后 变大很大?
- 如何在页面上存值??session容易掉,不知道原因。
- 弹出层 ,锁定页面!
- 横刀立马:谁能挑战高效分页存储过程(MS-SQL)?500元悬赏!!!
- 如何点图显示大图
- 为何能获取内嵌框架中页面中的控件但是却获取不到值,两个页面都在同一站点
- 小白求助“登录界面上输入用户和密码就出错”
- 急 asp.net 按钮事件中如何下载服务器端的exe文件
- OpenFlashChart2如何保存图片啊
<asp:HiddenField ID="HiddenFieldId" runat="server" Value='<%# Eval("ProjectId") %>' />用隐藏域存ProjectId,取的时候从隐藏域里面取就可以了
这里不是有答案了?
{
int ProjectId = Convert.ToInt32(e.CommandArgument);
}
是啊
你隐藏ID列
也可以从上次的方法获取啊
你上次用的我第一个方法
直接gridview.rows.cell
我不是还有另外一种
获取隐藏列的方法也发给你了么
<asp:HiddenField ID="ooxx" runat="server" Value='<%# Eval("ProjectId") %>' />
</asp:HiddenField> 你确定GridView 里面有这个属性?
GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
int index = gvrow.RowIndex;
//string id = DVClientInfo.Rows[index].Cells[1].Text.ToString();
string tNumber = DVClientInfo.DataKeys[index].Values["ProjectId"].ToString();index 会数组溢出?
是你ProjectId 没有存放在datakeys中吧
后台取值if (e.CommandName == "redact")//编辑
{
e.CommandArgument = "取值"
}
在左边工具栏 -->“标准”栏里面,你找找,拖进去设置一下就行了,和Gridview没关系
要不你把你查询数据的代码发出来看看
输入ProjectId 就OK
或者在源码中
<asp:GridView ID="GridView1" runat="server" DataKeyNames="ProjectId">
</asp:GridView>
/// 生成事件时激发
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void DVClientInfo_RowCommand(object sender, GridViewCommandEventArgs e)
{
//int strProjectId = Convert.ToInt32(e.Item.Cells[0].Text);
int strProjectId = 0; GridViewRow gvrow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
int index = gvrow.RowIndex;
string id = DVClientInfo.Rows[index].Cells[1].Text.ToString();
if (e.CommandName == "redact")//编辑
{ }
else if (e.CommandName == "forbid")//禁用
{
bool temp = centaline.Pro.ClassLibrary.Property.CProject.UpStatusF(strProjectId);
}
else if (e.CommandName == "comeback")//恢复
{
bool temp = centaline.Pro.ClassLibrary.Property.CProject.UpStatusR(strProjectId);
}
}
datakeys 属性加哪里呀?怎么加呀?
<asp:GridView ID="DVClientInfo" runat="server"onrowdatabound="DVClientInfo_RowDataBound" onrowcommand="DVClientInfo_RowCommand">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input id="Checkbox2" type="checkbox" runat="server" /><label>全选</label>
</HeaderTemplate>
<Headerstyle ForeColor="#333333" Height="24px" Width="60Px" Wrap="False" />
<Itemstyle HorizontalAlign="Center" Height="24px" />
</asp:TemplateField>
<asp:BoundField DataField="ProjectName" HeaderText="项目名称" >
</asp:BoundField>
<asp:BoundField DataField="ProjectCode" HeaderText="项目编号" >
</asp:BoundField>
<asp:BoundField DataField="orgName" HeaderText="隶属部门" >
</asp:BoundField>
<asp:BoundField DataField="Status" HeaderText="状态" >
</asp:BoundField>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<asp:LinkButton ID="lbtn_redact" runat="server" CommandName="redact" ForeColor="#0099FF">编辑</asp:LinkButton>
<asp:LinkButton ID="lbtn_forbid" runat="server" CommandName="forbid" ForeColor="#0099FF">禁用</asp:LinkButton>
<asp:LinkButton ID="lbtn_comeback" runat="server" CommandName="comeback" ForeColor="#0099FF">恢复</asp:LinkButton>
</ItemTemplate>
<Itemstyle HorizontalAlign="Center" />
</asp:TemplateField>
</Columns>
</asp:GridView>
这样行了,不要projectId,你绑它干嘛
绑他有用!呵呵!所用处理都要用到projectId!
<asp:HiddenField ID="HiddenFieldId" runat="server" Value='<%# Eval("ProjectId") %>' />
用隐藏域存ProjectId,取的时候从隐藏域里面取就可以了