RadioButton:
把autopostback 设置为true,事件才可以用
第二种方法:
用groupname包含两个radiobutton就可以不写事件了
12/25
CausesValidation="False"屏弊正则验证
lstRepertoireType.SelectedIndex = 0; 设选中默认值
12/26
分页查询问题:
因为查询默认是从首页,进行查询
解决方法:
一、在数据源绑定之前,把页数设为第"零"页
dgVersion.DataSource = dt;
dgVersion.CurrentPageIndex = 0;
dgVersion.DataBind();
12/28
1.无法查询字段为空的值 (SQL)
select * from doc_magazine where maTitle is null or maTitle =''
2.如何操作data grid 的link command
protected void dgFinalVersion_ItemCommand(object source, DataGridCommandEventArgs e)
{
if (e.CommandName.Equals("EditCommand"))
{
TableCell tblCell = e.Item.Cells[0];
Response.Redirect(WEBADMININFO_BROWSER + tblCell.Text);
}
}
tblCell.Text =可以取得ID
因为在Data Grid的第一列是ID,是用户手动设成隐藏的
//分页操作
protected void MyDataGrid_Page(Object sender, DataGridPageChangedEventArgs e)
{
startIndex = e.NewPageIndex * dgFinalVersion.PageSize;
dgFinalVersion.CurrentPageIndex = e.NewPageIndex;
//进行绑定数据的操作
}
12/28
/// <summary>
/// 取得下拉框中选的值
/// </summary>
/// <returns></returns>
private string getRepertoireItem()
{
string repertoireName = "";
foreach (DataGridItem Items in dgChoList.Items)
{
DropDownList ddl = (DropDownList)Items.FindControl("ddlRepertoire");
for (int i = 0; i < ddl.Items.Count; i++)
{
if (ddl.Items[i].Selected)
repertoireName = ddl.Items[i].Text.Trim();
break;
}
}
return repertoireName;
}
12/30
1.Session失效的问题
2.ArrayList 倒序排列
ArrayList infoId = new ArrayList();
DataTable chsedTbl = (DataTable)Session[CHOICE_LIST];
if (chsedTbl != null)
{
for (int iPos = chsedTbl.Rows.Count; iPos > 0; iPos--)
{
DataRow row = chsedTbl.Rows[iPos - 1];
if ((Boolean)row["checked"])
{
infoId.Add((String)row["id"]);
}
}
}
return infoId;
12/31
列计算
SELECT *, CAST(AdoptTime AS int) + CAST(AdoptTimeProvince AS int)
+ CAST(AdoptTimeCountry AS int) AS RowSum
FROM GOVINFO_WebAdminInfo
1/4
加上这句话:
InitializeComponent{
//拖动窗体,控件会跟窗口的长度改变而变化
this.treeCombo1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
}
还可以这样写
treeCombo1.ReadOnly =
dateCombo1.ReadOnly =
checkCombo1.ReadOnly = checkBox1.Checked;
1/7
思路:如果所在的页数是第7页,而当前的结果24条记录,这里如果分页只有2页,
这样 sourc.Count = 24
grid.PageSize = 12 (一页规定的记录数)
if(7>2) CurrentPageIndex =2
Else CurrentPageIndex =7
/// <summary>
/// 翻页判断,安全绑定
/// </summary>
/// <param name="grid"></param>
private void SecurityPaging(Datatable sourc, DataGrid grid){
if (sourc.Rows.Count > 0)
{
int tmp = sourc.Rows.Count / grid.PageSize;
if (grid.CurrentPageIndex > tmp)
grid.CurrentPageIndex = tmp;
}
}
private void SecurityPaging(ArrayList sourc, DataGrid grid)
{
if (sourc.Count > 0)
{
int tmp = sourc.Count / grid.PageSize;
if (grid.CurrentPageIndex > tmp)
grid.CurrentPageIndex = tmp;
}
}
SecurityPaging(resList, dgShare);
this.dgShare.DataSource = resList;
this.dgShare.DataBind();
cutClumnString(dgShare, 1);
/// <summary>
/// 显示字符长度截取
/// </summary> celIndex是DataGrid的索引号
/// <param name="aimDG"></param>
private void cutClumnString(DataGrid aimDG, int celIndex)
{
int max = 15;
for (int i = 0; i < aimDG.Items.Count; i++)
{
string oriStr = aimDG.Items[i].Cells[celIndex].Text.ToString();
if (oriStr.Length > max)
{
aimDG.Items[i].Cells[celIndex].Text = oriStr.Substring(0, max) + "..";
}
}
}
1/10
function DelTest(){
var j=0;
for (i = 0; i < this.form1.length; i++) {
if(this.form1[i].type == "checkbox"){
if (this.form1[i].checked){
j++;
}
}
}
if(j > 0) {
return confirm('你确认删除么?');
} else {
alert("请选择要删除的通知");
return false;
}
}
Pageload(){
btnDel.OnClientClick = "return DelTest()";
}