<asp:GridView runat="server" id="gv" DataKeyNames="CustomerID"
AutoGenerateColumns="False" onrowdatabound="gv_RowDataBound"
onrowcancelingedit="gv_RowCancelingEdit" onrowdeleting="gv_RowDeleting"
onrowediting="gv_RowEditing" onrowupdating="gv_RowUpdating">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="CustomerID"
DataNavigateUrlFormatString="./CustomerDetails.aspx?CustomerID={0}"
DataTextField="CustomerID" HeaderText="客户编号" />
<asp:BoundField DataField="CompanyName" HeaderText="客户名称" ReadOnly="True"
SortExpression="CompanyName" />
<asp:BoundField DataField="ContactName" HeaderText="联系人"
SortExpression="ContactName" />
<asp:BoundField DataField="ContactTitle" HeaderText="联系主题"
SortExpression="ContactTitle"/>
<asp:TemplateField HeaderText="城市">
<ItemTemplate>
<asp:DropDownList runat="server" ID="cityDpt"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
</Columns>
</asp:GridView>C#: protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string customerId = ((HyperLink)gv.Rows[e.RowIndex].Cells[0].Controls[0]).Text;
string companyName = gv.Rows[e.RowIndex].Cells[1].Text;
string contactName = gv.Rows[e.RowIndex].Cells[2].Text;
string contactTitle = gv.Rows[e.RowIndex].Cells[3].Text;
string city = (gv.Rows[e.RowIndex].FindControl("cityDpt") as DropDownList).SelectedItem.Text; }companyId和companyName都能获取到值,但是contactName和contactTitle都获取不到,为什么啊
解决方案 »
- VS2005 性能分析 出现“性能报告***.vsp不包含数据”的错误
- 1个按钮 要先执行CS里的事件 然后在执行JS里的事件
- 为什么我一旦在aspx.vb里面调用dataset就提示如下信息。
- .NET下的XML序列化
- 为什么我的一个button不好用呢?点击后click事件不响应,没有反应?????
- 求数据集下的ROWS 对象的一个方法find的用法。
- 请问if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem){这个语句中的字符"||"是什么意思,用vb.ne
- treeview 的简单问题
- 新增数据问题!!
- 关于DropDownList的触发事件
- 200分进
- 实现3级动态菜单
你这样的就可以了!