repeater取值问题
前台代码:
<ItemTemplate>
<tr>
<td align="left">
<asp:CheckBox ID="cb_id" CssClass="checkall" runat="server" />
</td>
<td align="left">
<asp:ImageButton ID="ibtnLock" CommandName="ibtnLock" runat="server" ImageUrl='<%# Convert.ToInt32(Eval("NIsLock")) == 1 ? "Images/correct.gif" : "Images/disable.gif"%>'
ToolTip='<%# Convert.ToInt32(Eval("NIsLock")) == 1 ? "取消锁定" : "设置锁定"%>' />
<asp:ImageButton ID="ibtnTop" CommandName="ibtnTop" runat="server" ImageUrl='<%# Convert.ToInt32(Eval("NIsTop")) == 1 ? "Images/ico-1.png" : "Images/ico-1_.png"%>'
ToolTip='<%# Convert.ToInt32(Eval("NIsTop")) == 1 ? "取消置顶" : "设置置顶"%>' />
</td>
</tr>
</ItemTemplate>
后台代码:
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
int id = Convert.ToInt32(((Label)e.Item.FindControl("lb_id")).Text);
string str;
str = "select * from T_News where Nid=" + id;
DataTable dt = DbHelper.GetDataTable(str);
switch (e.CommandName.ToLower())
{
case "ibtnlock":
if (dt.Rows[0]["NIsLock"].ToString() == "1")
{
str = "update T_News set NIsLock=0 where Nid= " + id;
try
{
DbHelper.NoResultCommand(str);
}
catch (Exception)
{
throw;
}
}
else
{
str = "update T_News set NIsLock=1 where Nid= " + id;
try
{
DbHelper.NoResultCommand(str);
}
catch (Exception)
{
throw;
}
}
break;
case "ibtntop":
if (dt.Rows[0]["NIsTop"].ToString() == "1")
{
str = "update T_News set NIsTop=0 where Nid= " + id;
try
{
DbHelper.NoResultCommand(str);
}
catch (Exception)
{
throw;
}
}
else
{
str = "update T_News set NIsTop=1 where Nid= " + id;
try
{
DbHelper.NoResultCommand(str);
}
catch (Exception)
{