求方法代码

0 1看天下 2010-12-30 11:33:03
表有两列A,B
怎么在选择A列(下拉框)中数据时,B列显示相应的内容
比如,A中有学生a,但选择a时,B列显示学生a,出生于...,即相关描述
此描述为针对A中数据的,可以在程序中写
...全文
176 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
老白干 2010-12-30
  • 打赏
  • 举报
回复
http://blog.csdn.net/pvfhv/archive/2010/12/24/6095534.aspx
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 timzhufaith 的回复:]
引用 4 楼 flashyyp123 的回复:
引用 2 楼 li309000011 的回复:
没太明白你的意思

选了学生名字A 对应的下拉列表也就取到了key或者其他的什么什么可以做条件的东西
然后 select b from table where key=“key”

这样就取到B了 你想怎么处理就怎么处理呗?
B是在选择了A列中下拉框的数据以后,才自动显示的,不是从表中取……
[/Quote]A列中不能编辑,只能从下拉框中选择
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复

这是我写的部分代码
private void AfterRowColChange(object sender, EventArgs e)
{
object[] args = new object[] { "学生1", "学生2", "学生3" };
string flag = this.student.Rows[0]["A"].ToString();
switch (flag)
{
case "1":
this.student.Rows[0]["B"] = args[0];
break;
case "2":
this.student.Rows[0]["B"] = args[1];
break;
case "3":
this.student.Rows[0]["B"] = args[2];
break;
}
}
我要的是A中数据选择时,比如选1,B列自动显示 学生1 的描述,而不是从表中去读
TimZhuFaith 2010-12-30
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 flashyyp123 的回复:]
引用 2 楼 li309000011 的回复:
没太明白你的意思

选了学生名字A 对应的下拉列表也就取到了key或者其他的什么什么可以做条件的东西
然后 select b from table where key=“key”

这样就取到B了 你想怎么处理就怎么处理呗?
B是在选择了A列中下拉框的数据以后,才自动显示的,不是从表中取的,要在程序中定义
[/Quote]A列的值是可以编辑或者添加的么。。。如果不是,swtich解决!A,B的键值设为有关系的即可
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 li309000011 的回复:]
没太明白你的意思

选了学生名字A 对应的下拉列表也就取到了key或者其他的什么什么可以做条件的东西
然后 select b from table where key=“key”

这样就取到B了 你想怎么处理就怎么处理呗?
[/Quote]B是在选择了A列中下拉框的数据以后,才自动显示的,不是从表中取的,要在程序中定义
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
恩,可能是联动的问题,比如公司分为1,2,3存在A中,但选择1是B中自动显示1为一级公司的描述
li309000011 2010-12-30
  • 打赏
  • 举报
回复
没太明白你的意思

选了学生名字A 对应的下拉列表也就取到了key或者其他的什么什么可以做条件的东西
然后 select b from table where key=“key”

这样就取到B了 你想怎么处理就怎么处理呗?
在路上20130607 2010-12-30
  • 打赏
  • 举报
回复
是不是联动问题 没怎么看懂
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
看来都挺忙的,算了,结贴给分!!!
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
[Quote=引用 21 楼 flashyyp123 的回复:]
for (int i = 0; i < yytdictGrid1.Grid.Rows.Count; i++)
{
if (this.dictReference1.SelectedValue != null)
{
string flag = "";
flag = dictReference1.SelectedValue;
switch (flag)
{
……
[/Quote]我自己回答了i=1
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
for (int i = 0; i < yytdictGrid1.Grid.Rows.Count; i++)
{
if (this.dictReference1.SelectedValue != null)
{
string flag = "";
flag = dictReference1.SelectedValue;
switch (flag)
{
case "2LA110260Q":
this.yytdictGrid1.Grid.Rows[i]["SLEVELDESC"] = args[0];
break;
case "2":
this.yytdictGrid1.Grid.Rows[i]["SLEVELDESC"] = args[1];
break;
case "3":
this.yytdictGrid1.Grid.Rows[i]["SLEVELDESC"] = args[2];
break;
}
}
}怎么在加载的时候列名也该了呢?只要列的数据变咋整?
guohongxu1988 2010-12-30
  • 打赏
  • 举报
回复
可不可以做个事件
yezhendong185 2010-12-30
  • 打赏
  • 举报
回复
获取你选择的A的索引,在根据获取的值进行对应操作并选择在B中。
foxwfb 2010-12-30
  • 打赏
  • 举报
回复
A列数据的变动,引发事件,,事件当中根据数据来重新查询数据库数据,加载到B列当中
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
还有列A的下拉框是用参照做的,事件是应该写参照的还是grid的
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
很遗憾,我的不能实现
huminghua 2010-12-30
  • 打赏
  • 举报
回复
在A中弄个事件撒!联动问题!可以啊!楼上的应该可以实现!
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
private void yytdictGrid1_AfterSelChange(object sender, C1.Win.C1FlexGrid.RangeEventArgs e)
{
object[] args = new object[] { "一级公司", "二级公司", "三级公司" };
string flag = "";
dictReference1.SelectedValue = flag;
if (this.dictReference1.SelectedValue != null)
{
switch (flag)
{
case "甘肃金轮文化传媒有限公司武威分公司":
this.ps_perm.Rows[0]["SLEVELDESC"] = args[0];
break;
case "2":
this.ps_perm.Rows[0]["SLEVELDESC"] = args[1];
break;
case "3":
this.ps_perm.Rows[0]["SLEVELDESC"] = args[2];
break;
}
}
}这样行吗?
0 1看天下 2010-12-30
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 wuyq11 的回复:]
dropdownlist中绑定数据,autopostbak=true
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
……
[/Quote]这能实现 “A中数据选择时,比如选1,B列自动显示 学生1 的描述,”的功能吗?
wuyq11 2010-12-30
  • 打赏
  • 举报
回复
dropdownlist中绑定数据,autopostbak=true
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ddlLB" runat="server" Width="15%" AutoPostBack="True" OnSelectedIndexChanged="ddlLB_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList ID="ddlChild" runat="server" Width="20%">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
protected void ddlLB_SelectedIndexChanged(object sender, EventArgs e)
{
if(this.ddlLB.SelectedValue!=null)
{
BindChild(this.ddlLB.SelectedValue);
}
}

DropDownList2.DataSource=lst;
DropDownList2.DataValueField="name";
DropDownList2.DataTextField="name";
DropDownList2.DataBind();
加载更多回复(2)

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧