datagrid中代码:

<asp:datagrid id="dgList" runat="server" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
HorizontalAlign="Center" PageSize="5" AutoGenerateColumns="False" GridLines="Horizontal" CellPadding="1" BackColor="White"
BorderWidth="1px" BorderStyle="None" BorderColor="#E7E7FF" Width=100% OnItemDataBound="DataGrid1_ItemDataBound">
<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#738A9C"></SelectedItemStyle>
<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
<ItemStyle HorizontalAlign="Center" ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle>
<Columns>
<asp:templatecolumn HeaderText="状态">
<itemtemplate>
<asp:dropdownlist id="ItemDropDown" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDown_SelectedIndexChanged"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button id="SaveButton" Visible="false" runat="server" CommandName="save" Text="保存"></asp:Button>
</ItemTemplate>
</asp:templatecolumn>
<PagerStyle ForeColor="#4A3C8C" BackColor="#E7E7FF" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
private void InitializeComponent()
{
this.dgList.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgList_ItemCommand);
} protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item)
{
string[] options = { "", "已通知", "变更邮箱中", "联系不上", "商户要注销" }; DropDownList list = (DropDownList)e.Item.FindControl("ItemDropDown");
list.DataSource = options;
list.DataBind(); TableCell cell = list.Parent as TableCell;
DataGridItem item = cell.Parent as DataGridItem; int index = item.ItemIndex;
list.SelectedValue = item.Cells[].Text;
}
} protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList list = (DropDownList)sender; TableCell cell = list.Parent as TableCell;
DataGridItem item = cell.Parent as DataGridItem; int index = item.ItemIndex;
string content = item.Cells[].Text;
// DropDownList down = (DropDownList)item.FindControl("ItemDropDown");
string checkState = list.SelectedValue.Trim(); object obj = item.Cells[].FindControl("queryButton");
if (obj != null)
{
Button lb = (Button)obj;
lb.Visible = true;//动下拉列表就显示保存按钮
}
} private void dgList_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string spid = e.Item.Cells[].Text.Trim();
string crt_etime = e.Item.Cells[].Text.Trim();
string state = e.Item.Cells[].Text.Trim(); try
{
if (e.CommandName == "save") ;
…………………………//保存
}
catch (Exception eSys)
{
WebUtils.ShowMessage(this.Page, "保存数据失败!" + eSys.Message);
}
}

datagrid加下拉列表dropdownlist的更多相关文章

  1. PHP+Mysql+easyui点击左侧tree菜单对应表名右侧动态生成datagrid加载表单数据(二)

    关于tree菜单生成,参考我的另一篇博文地址tree 菜单 实现功能:点击左侧tree菜单中的table,右侧通过datagrid加载出该表对用的所有数据 难点:获取该表的所有列名,动态生成datag ...

  2. jquery easyui datagrid 加每页合计和总合计

    jquery easyui datagrid 加每页合计和总合计 一:效果图 二:代码实现 这个只有从后台来处理 后台根据rows 和page两个参数返回的datatable 命名为dt 然后根据dt ...

  3. jquery easyui使用(三)······datagrid加载数据(已解决)

    <div id="table_Data"> </div> $("#table_Data").datagrid({ toolbar: '# ...

  4. easyui datagrid 加载两次请求,触发两次ajax 请求 问题

    datagrid初始化的时候请求两次URL 两种情况 1. <table id="gridview" class="easyui-datagrid"> ...

  5. 解决easyui datagrid加载数据时,checkbox列没有根据checkbox的值来确定是否选中

    背景:   昨天帮朋友做一个easyui datagrid的小实例时,才发现easyui datagrid的checkbox列,没有根据值为true或false来选中checkbox,当时感觉太让人失 ...

  6. easyui datagrid加载数据的三种方式

    1.加载本地数据 var obj = {"total":2,"rows":[{id:"1",name:"一"},{id: ...

  7. Easyui datagrid加载数据时默认全选的问题

    问题描述: 最近使用 Easyui datagrid 展示数据,之前一直使用很正常,今天出现了一个怪异问题 加载数据后,只要点击选中列 ck 的任意行或多行,再刷新时整个datagrid的所有数据都 ...

  8. wpf DataGrid加载行号

    <DataGrid Name="tkdg" HorizontalContentAlignment="Center" AutoGenerateColumns ...

  9. easyui datagrid加载成功之后选定并获取首行数据

    //加载成功之后,选定并获取首行数据 onLoadSuccess:function(data){ alert("grid加载成功"); var rows=$('test').dat ...

随机推荐

  1. NLP相关资源

    一 NLP相关资源站点 Rouchester大学NLP/CL会议列表 一个非常好的会议时间信息网站,将自然语言处理和计算语言学领域的会议,按照时间月份顺序列出. NLPerJP 一个日本友好人士维护的 ...

  2. 深入浅出C语言中的堆和栈

    在谈堆栈的时候,我在这有必要把计算机的内存结构给大家简单的介绍下(高手们可以直接飘过) 一. 内存结构   每个程序一启动都有一个大小为4GB的内存,这个内存叫虚拟内存,是概念上的,真正能用到的,只是 ...

  3. Spring MVC 教程,快速入门,深入分析(转载)

    作者:赵磊 博客:http://elf8848.iteye.com 下载: Spring的官方下载网址是:http://www.springsource.org/download    (本文使用是的 ...

  4. Lesson 6: CronTrigger

    CronTrigger is often more useful than SimpleTrigger, if you need a job-firing schedule that recurs b ...

  5. java 实现多种排序

    public class Sort {        //交换两个数    private void swap(int[] arr, int i,int j){        int temp = a ...

  6. 【HDOJ】2822 Dogs

    bfs. /* 2822 */ #include <iostream> #include <cstdio> #include <cstring> #include ...

  7. bzoj3531

    不难想到树链剖分这题的难点是记录的是路径上宗教相同的点裸的想法是对每一种宗教都开一棵线段树,记录每个点的评级但显然这样会爆空间,仔细分析一下,这些线段树内很多点压根就没用到因此我们考虑对线段树动态开点 ...

  8. 【Fiddler】手机抓包

    Fiddler (四) 实现手机的抓包 手机配置了后,Fiddler不开起来就什么也连接不了

  9. 数据结构——foodfill 八连块问题

    Description Due to recent rains, water has pooled in various places in Farmer John's field, which is ...

  10. bzoj 1010 [HNOI2008]玩具装箱toy(DP的斜率优化)

    1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 7874  Solved: 3047[Submit][St ...