作成日: 2015/01/21 最終更新日: 2015/01/21
文書種別
使用方法
詳細
下記コードのようにItemTemplateを使用してグリッドにCheckBoxまたはC1ComboBoxを配置することができます。
◎サンプルコード(aspx)
このようにItemTemplateを使用して配置されたCheckBoxまたはC1ComboBoxの値を取得するにはFindControlメソッドを使用してコンポーネントを参照します。
ボタンのクリックイベントにて各行のCheckBox1、C1ComboBox1の値を取得する場合は下記コードのようになります。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(aspx)
<wijmo:C1GridView ID="C1GridView1" runat="server" …>
<Columns>
…
<wijmo:C1TemplateField …>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" … />
</ItemTemplate>
</wijmo:C1TemplateField>
<wijmo:C1TemplateField …>
<ItemTemplate>
<wijmo:C1ComboBox ID="C1ComboBox1" runat="server" …></wijmo:C1ComboBox>
</ItemTemplate>
</wijmo:C1TemplateField>
</Columns>
</wijmo:C1GridView>
<Columns>
…
<wijmo:C1TemplateField …>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" … />
</ItemTemplate>
</wijmo:C1TemplateField>
<wijmo:C1TemplateField …>
<ItemTemplate>
<wijmo:C1ComboBox ID="C1ComboBox1" runat="server" …></wijmo:C1ComboBox>
</ItemTemplate>
</wijmo:C1TemplateField>
</Columns>
</wijmo:C1GridView>
このようにItemTemplateを使用して配置されたCheckBoxまたはC1ComboBoxの値を取得するにはFindControlメソッドを使用してコンポーネントを参照します。
ボタンのクリックイベントにて各行のCheckBox1、C1ComboBox1の値を取得する場合は下記コードのようになります。
◎サンプルコード(VB)
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' 行のループ
For Each row As C1.Web.Wijmo.Controls.C1GridView.C1GridViewRow In C1GridView1.Rows
Dim checkboxValue As [String] = DirectCast(row.FindControl("CheckBox1"), CheckBox).Checked.ToString()
Dim comboboxValue As [String] = DirectCast(row.FindControl("C1ComboBox1"), C1ComboBox).SelectedItem.Text
Next
End Sub
' 行のループ
For Each row As C1.Web.Wijmo.Controls.C1GridView.C1GridViewRow In C1GridView1.Rows
Dim checkboxValue As [String] = DirectCast(row.FindControl("CheckBox1"), CheckBox).Checked.ToString()
Dim comboboxValue As [String] = DirectCast(row.FindControl("C1ComboBox1"), C1ComboBox).SelectedItem.Text
Next
End Sub
◎サンプルコード(C#)
protected void Button1_Click(object sender, EventArgs e)
{
// 行のループ
foreach (C1.Web.Wijmo.Controls.C1GridView.C1GridViewRow row in C1GridView1.Rows)
{
String checkboxValue = ((CheckBox)(row.FindControl("CheckBox1"))).Checked.ToString();
String comboboxValue = ((C1ComboBox)(row.FindControl("C1ComboBox1"))).SelectedItem.Text;
}
}
{
// 行のループ
foreach (C1.Web.Wijmo.Controls.C1GridView.C1GridViewRow row in C1GridView1.Rows)
{
String checkboxValue = ((CheckBox)(row.FindControl("CheckBox1"))).Checked.ToString();
String comboboxValue = ((C1ComboBox)(row.FindControl("C1ComboBox1"))).SelectedItem.Text;
}
}
旧文書番号
81141