середа, 23 грудня 2009 р.

not null -> true and null -> false


select
CASE
when ImageFile is NULL then 0
else 1
end as HasImage
from News

Bind to ItemIndex

Repeater:
<% #DataBinder.Eval(Container, "ItemIndex") %>
Gridview:
<% #DataBinder.Eval(Container, "RowIndex") %>

четвер, 29 жовтня 2009 р.

Footer always bottom



HTML:

<div id="container">
<div id="main">
<div id="header">
<h2>
header
</h2>
</div>
<div id="content">
<h2>
content content content content<br />
content content content content<br />
content content content content<br />
content content content content<br />
</h2>
</div>
</div>
</div>
<div id="footer">
<h2>
footer
</h2>
</div>

CSS:

*{padding:0; margin:0;}
html {height: 100%;}
body {height: 100%;}
#container {min-height: 100%;}
* html #container {height: 100%;}
#header {height: 110px;}
#footer {height: 90px;position: relative;margin-top:-90px;}
#main {min-height: 100%;}
* html #main{height: 100%;}
#content {padding-bottom: 90px;}

#header{background:red;}
#container {background:#aaa;}
#content{background:green;}
#footer{background:blue;}

Body min-height 100%


html
{
height:100%;
}
body
{
margin:0px;
min-height:100%;
height:100%;
height:auto !important;
}

Div min-height


#content
{
min-height:400px;
height:auto !important;
height:400px;
}

середа, 29 липня 2009 р.

GridView + autopostback CheckBox


в темплейтах колонок прописуємо:

asp:CheckBox ID="chb1" AutoPostBack="true"
key='<%# Eval("ID") %>'
runat="server"
OnCheckedChanged="chb1_CheckedChanged"

а в коді:
protected void chb1_CheckedChanged(object sender, EventArgs e)
{
CheckBox chb = (CheckBox)sender;
string id = chb.Attributes["key"];
...
}

вівторок, 14 липня 2009 р.

Validation of ViewState Mac failed

Від цієй проблеми допоможуть наступні параметри розділу pages в web.config:

validateRequest="false"
enableEventValidation="false"
viewStateEncryptionMode ="Never"