我有一个包含以下列的GridView。
父ID具有子ID。如果我选择Parent ID组合框为YES,则所有子值应填充为YES。
我想在客户端使用Java Script执行此操作。你能指导我吗?
<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;
}