当触发onrowediting的时候,所有列都变成可编辑可修改,但是我只希望能改其中的一个列,其它列不允许修改
应该怎么设置啊?还是要代码写的???
应该怎么设置啊?还是要代码写的???
解决方案 »
- 请教用户登录以后显示数据问题
- 下载问题
- .aspx.cs调用.cs静态类问题.
- 这样的定义分页可行吗?效率如何?
- 求AspNetPager的VB代码例子。
- 请高人帮我调通这个存储过程,很简单!!!!谢谢
- 用Request.QueryString取值,为什么不可正常显示中文了.是不是我的机子有问题?
- 请问如何在Web Form 的 DataGrid 中 绑定 Dropdownlist?
- [求]用File类删除局域网内其它计算机上的文件的方法
- ASP生成jpg图片
- 急,多条sql绑定到GridView中。。。
- 目前最稳定的(sql server版本+windows服务器系统版本+Microsoft vs版本)
dropdownlist.selectItem.value
都不对的啊
DropdownList ddlMyList=e.Row.cells[i].FindControl("控件id") as DropdownList ;
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
DropDownList list = (DropDownList)(GridView1.Rows[e.RowIndex].Cells[0].FindControl("DropDownList1"));
string result = list.SelectedItem.Text.ToString();
GridView1.EditIndex = -1;
DBBind();
if (((Label)(GridView1.Rows[e.RowIndex].Cells[0].FindControl("Label1"))) != null)
{
((Label)(GridView1.Rows[e.RowIndex].Cells[0].FindControl("Label1"))).Text = result;
}
}
页面设置
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" onrowdatabound="GridView1_RowDataBound"
style="margin-left: 0px" onrowcancelingedit="GridView1_RowCancelingEdit"
onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating">
<Columns>
<asp:TemplateField HeaderText="问题" SortExpression="Question">
<EditItemTemplate>
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Bind("Question") %>' />
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("Question") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ApplyDate" HeaderText="日期" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
{
gv.EditIndex = e.RowIndex;
int id = int.Parse(gv.DataKeys[e.RowIndex].Value.ToString());
string str = ((TextBox)gv.Rows[e.RowIndex].FindControl("txt")).Text.Trim();
gv.EditIndex = -1;
BindData();
}
<asp:TemplateField HeaderText="性别" SortExpression="Gender">
<ItemTemplate>
<%#(Eval("Gender")).ToString() =="True"?"男":"女"%>
</ItemTemplate>
<EditItemTemplate>
<asp:RadioButtonList ID="uGender" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="男"></asp:ListItem>
<asp:ListItem Text="女"></asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
</asp:TemplateField>
设置编辑Linkbutton edit