本文介绍了从Datalist获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在datalist中显示值,每行都有复选框,因此在加载页面后,当复选框被更改时,我需要做一些计算,
在标签中存储标识列值并使其显示为false
所以任何人都可以帮助找到标识列值选中复选框的确切行,我将通过oncheckedchange事件进行计算...
Hi,
I am showing the values in datalist and in each row i have checkbox, so after loading the page, when when the checkbox is changed i need to do some calculations,
Storing the identity column values in label and made visible false
so can anyone help to find the identity column value at which exact row the checkbox is checked,i would do the calculation by oncheckedchange event...
推荐答案
int count = dl.Items.Count;
for (int i = 0; i < count; i++)
{
Checkbox chk = dl.Items[i].FindControl("chkID") as Checkbox;
if(chk.Checked)
{
Label ID = dl.Items[i].FindControl("lblID") as Label;
string item = ID.Text;
// if more than one is checked, continue the loop and track all the texts.
// Like: string selectedItemTexts += ID.Text + ",";
}
}
这篇关于从Datalist获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!