设置组合框值客户端
GridView Set ComboBox value Client side
我有一个GridView,包含以下列。
- 父ID -绑定列
- 子ID -绑定列
- 指定绑定列
- 状态为值为YES, NO的组合框
Parent ID有Child ID。如果我选择父ID组合框为YES,那么所有子值都应该填充为YES。
我想在客户端使用Java脚本。你能给我指路吗?
<asp:datagrid id="dgImpact" runat="server" Width="78%" CellSpacing="0" AlternatingItemStyle-Height="20px"
AutoGenerateColumns="False" BorderColor="#3A6EA5" ItemStyle-ForeColor="blue"
CellPadding="0" BorderWidth="0px">
<AlternatingItemStyle Height="20px" BackColor="#EEF5FB"></AlternatingItemStyle>
<ItemStyle Height="20px" ForeColor="DarkBlue" BackColor="#DCEDF9"></ItemStyle>
<HeaderStyle Font-Names="Estrangelo Edessa" Font-Bold="True" Wrap="False" ForeColor="White" BorderColor="#336491"
BackColor="#336491"></HeaderStyle>
<Columns>
<asp:ButtonColumn>
<ItemStyle Width="20px"></ItemStyle>
</asp:ButtonColumn>
<asp:ButtonColumn>
<ItemStyle Width="20px"></ItemStyle>
</asp:ButtonColumn>
<asp:ButtonColumn>
<ItemStyle Width="20px"></ItemStyle>
</asp:ButtonColumn>
<asp:BoundColumn Visible="False" DataField="QuestionID" ReadOnly="True">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Wrap="False" HorizontalAlign="Left"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Questions">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="320px"></ItemStyle>
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.QuestionDesc") %>' ID="Label1">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Status">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle Wrap="False" HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:dropdownlist CssClass="ComboStyle" Visible="True" Runat="server" ID="cmbAnswers" Width="72px" SelectedValue='<%# Bind("Status") %>'
DataSource='<%# (new string[] { "--Select--","Yes", "No", "NA","Unknown" }) %>'></asp:dropdownlist>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
cs
protected void Page_Load(object sender, EventArgs e)
{
DataSet dstQuesData = getRiskDisciplineQuestionAnswer();
dgImpact.DataSource = dstQuesData;
dgImpact.DataBind();
DataTable dtFinalTable = dstQuesData.Tables[0];
for (int intRowCount = 0; intRowCount <= dgImpact.Items.Count - 1; intRowCount++)
{
long a = Convert.ToInt64(dtFinalTable.Rows[intRowCount][9]);
/// 'If the Question Display is root
if (a.ToString().Length == 3)
{
((DataGridItem)dgImpact.Items[intRowCount]).Cells[4].ColumnSpan = 4;
dgImpact.Items[intRowCount].Cells[0].Visible = false;
dgImpact.Items[intRowCount].Cells[1].Visible = false;
dgImpact.Items[intRowCount].Cells[2].Visible = false;
//If the Question Displayed is at Level 1
}
else if (a.ToString().Length == 6 )
{
((DataGridItem)dgImpact.Items[intRowCount]).Cells[4].ColumnSpan = 3;
dgImpact.Items[intRowCount].Cells[0].Visible = true ;
dgImpact.Items[intRowCount].Cells[1].Visible = false;
dgImpact.Items[intRowCount].Cells[2].Visible = false;
//If the Question Displayed is at Level 2
}
else if (a.ToString().Length == 9)
{
((DataGridItem)dgImpact.Items[intRowCount]).Cells[4].ColumnSpan = 2;
dgImpact.Items[intRowCount].Cells[0].Visible = true;
dgImpact.Items[intRowCount].Cells[1].Visible = true;
dgImpact.Items[intRowCount].Cells[2].Visible = false;
}
else if (a.ToString().Length == 12)
{
((DataGridItem)dgImpact.Items[intRowCount]).Cells[4].ColumnSpan = 1;
dgImpact.Items[intRowCount].Cells[0].Visible = true;
dgImpact.Items[intRowCount].Cells[1].Visible = true;
dgImpact.Items[intRowCount].Cells[2].Visible = true;
}
}
}
public DataSet getRiskDisciplineQuestionAnswer()
{
DataSet riskQuestionAnswerData = new DataSet();
sqlConnection = new SqlConnection(connStr);
sqlCommand = new SqlCommand("usp_testRDD1", sqlConnection);
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlDataAdapter = new SqlDataAdapter(sqlCommand);
try
{
sqlDataAdapter.Fill(riskQuestionAnswerData);
}
catch
{
throw;
}
return riskQuestionAnswerData;
}
找不到合适的解决方案。
请看看这个链接。我希望这对你有帮助。
相关文章:
- 客户端服务器REST API captcha实现
- 使用谷歌应用程序脚本将服务器端数据表返回到客户端
- 如何使用Socket.io将命令从客户端发送到服务器
- 如何轻松地将服务器端变量从Java代码转移到客户端代码
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- 从客户端获取修改后的对象,并将其与服务器上的原始对象组合
- 如何将我的javascript库公开给其他客户端使用
- 是否可以使用JavaScript/AAJAX在客户端创建一个文件
- 如何使用Javascript客户端对象模型检索Sharepoint 2010列表项权限
- 返回/从Twit's客户端.get
- 将客户端特定的日期格式返回到服务器MVC4
- MobileFirst:在客户端运行计时器作业-最佳选项
- 标签客户端的设置值
- ZK:如何使用JavaScript在客户端填充ZK组合框
- 如何在客户端单击时将焦点设置在 DevExpress 组合框的“SelectedIndexChange”事件的
- 按值获取下拉列表/组合框的索引(客户端)
- 级联Telerik组合框在客户端数据绑定后记住选定的值
- 用于Node.js的Interactive Brokers TWS API客户端库-组合订单
- 当使用存储远程筛选器加载数据时,如何在客户端筛选组合框
- 设置组合框值客户端