我想在通过DataGrid外的一个按钮来向DataGrid里增加一个空行,也就是实现增加功能,空行里我都设置好全是文本框。帮忙!!!!!!!!!
解决方案 »
- sw.WriteLine(" "title":{ ");报错
- repeater获取行号
- asp.net模板if标签
- 安装Dreamweaver无法预览网页的问题
- 如何解决access数据库查询和读写的冲突
- 使用Response.WriteFile下载文件出现的奇怪问题!请各位指点指点!
- 麻烦帮我看看这段web.config里连接数据库的代码,为什么还是连接的是默认数据库
- 对FCKeditor了解的高手请进……
- 求助 rewrite 重写个url
- 又一个问题,crystaldecisions.shared 找不到一个依赖项
- 如果机器装了.net 1.0 和 1.1, 要在哪里设置已经用 1.0 开发好的aspx 与 .net 版本的关联?
- 哪里有新闻发布的无限级分类(象动网的那样)示例
AutoGenerateColumns="False" ShowFooter="True" Font-Size="10pt" AllowPaging="True" PageSize="20">
<EditItemStyle ForeColor="White" BackColor="RoyalBlue"></EditItemStyle>
<AlternatingItemStyle BackColor="#FFFFC0"></AlternatingItemStyle>
<ItemStyle BackColor="Bisque"></ItemStyle>
<HeaderStyle ForeColor="White" BackColor="#C04000"></HeaderStyle>
<FooterStyle BackColor="Olive"></FooterStyle>
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="更新" CancelText="取消" EditText="编辑"></asp:EditCommandColumn>
<asp:ButtonColumn Text="删除" CommandName="Delete"></asp:ButtonColumn>
<asp:TemplateColumn HeaderText="ID">
<ItemTemplate>
<asp:Label id="Label4" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.id") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton id="LinkButton1" runat="server" CommandName="Insert">Insert</asp:LinkButton>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="title">
<ItemTemplate>
<asp:Label id=Label3 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.title") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="Textbox3" runat="server" Width="200"></asp:TextBox>
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox id=TextBox5 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.title") %>' Width="200">
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="url">
<ItemTemplate>
<asp:Label id="Label2" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.url") %>'>
</asp:Label>
</ItemTemplate>
<FooterTemplate>
<INPUT type="file" runat="server" id="file1">
</FooterTemplate>
<EditItemTemplate>
<asp:TextBox id="TextBox1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.url") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle BorderWidth="1px" BorderColor="#FFC080" BorderStyle="Solid"></PagerStyle>
</asp:DataGrid>=============private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
...
}
}
{
// Customize the footer section with an image.
if(e.Item.ItemType == ListItemType.Footer)
{
// Create an Image control.
Image NewImageControl = new Image(); // Set the properties of the Image control.
NewImageControl.ImageUrl = "Image1.jpg";
NewImageControl.AlternateText = "Image 1"; // Add the Image control to the Controls collection of the
// cell representing the third column in the DataGrid.
e.Item.Cells[2].Controls.Add(NewImageControl); }
private void BindGrid()
{
SqlConnection myConnection = new SqlConnection(Application["DSN"].ToString());
SqlDataAdapter myCommand = new SqlDataAdapter("SELECT Id, Week_Id, str1, str2, Ocu_Date, Price, str4 FROM abc", myConnection);
DataSet ds = new DataSet();
try
{
myConnection.Open();
myCommand.Fill(ds, "att"); DataRow dr;
dr=ds.Tables["att"].NewRow();
dr["str1"]="";
dr["str2"]="";
dr["Ocu_Date"]=DBNull.Value;
dr["Price"]=DBNull.Value;
dr["str4"]="";
dr["id"]=0; ds.Tables["att"].Rows.Add(dr); if(ds.Tables[0].Rows.Count==0)
{
LinkButton14.Text = "显示";
} dg.DataSource=ds;
dg.DataBind();
}
catch(SqlException e)
{
Msg.ForeColor = Color.Red;
Msg.Text = e.Message;
return;
}
finally
{
myConnection.Close();
}
=================================
right!