private void Bind()
{
String P_id = Request.QueryString["P_id"].ToString();
SqlConnection con = Dcon.createConnection();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select *, '../../'+P_img as P_img1 from Product where P_id='" + P_id + "'", con);
DataSet ds = new DataSet();
sda.Fill(ds, "pro");
this.Pr_dtl.DataSource = ds.Tables["pro"];
this.Pr_dtl.DataBind();
}还有一个text控件:
<asp:TextBox ID="pid" runat="server"></asp:TextBox>如何的把pid 这个值賦給 text??
{
String P_id = Request.QueryString["P_id"].ToString();
SqlConnection con = Dcon.createConnection();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select *, '../../'+P_img as P_img1 from Product where P_id='" + P_id + "'", con);
DataSet ds = new DataSet();
sda.Fill(ds, "pro");
this.Pr_dtl.DataSource = ds.Tables["pro"];
this.Pr_dtl.DataBind();
}还有一个text控件:
<asp:TextBox ID="pid" runat="server"></asp:TextBox>如何的把pid 这个值賦給 text??
{
pid.text =dataset.Tables["pro"].Rows[i][0].ToString();
}
不知道对lz的意思有没理解对
<asp:TextBox ID="pid" runat="server" Text=' <%# Eval("pid") >) %>'> </asp:TextBox>
<%# Eval("pid") 是你查询表中的列名字
看看吧。
Height="85px" Width="574px" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="P_id" HeaderText="ID"/>
<asp:BoundField DataField="P_name" HeaderText="NAME" />
<asp:BoundField DataField="P_type" HeaderText="TYPE" SortExpression="P_type" />
<asp:BoundField DataField="P_ttype" HeaderText="E-TYPE" SortExpression="P_ttype" />
<asp:BoundField DataField="P_link" HeaderText="LINk" />
<asp:ImageField DataImageUrlField="P_img1" HeaderText="IMAGE">
<ControlStyle Height="356px" Width="500px" />
</asp:ImageField>
</Fields>
<FieldHeaderStyle Width="200px" HorizontalAlign="Center" />
</asp:DetailsView>
{
Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
if (!this.IsPostBack)
{ this.Bind();
}
}
{
String P_id = Request.QueryString["P_id"].ToString();
SqlConnection con = Dcon.createConnection();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand("select *, '../../'+P_img as P_img1 from Product where P_id='" + P_id + "'", con);
DataSet ds = new DataSet();
sda.Fill(ds, "pro");
this.Pr_dtl.DataSource = ds.Tables["pro"];
this.Pr_dtl.DataBind();
}
是这道理 你那个textbox 都不是在gridview的模板列里头 你绑定了也不会显示出来值啊
都什么年代了,用objectdatasource