【发布时间】:2018-03-11 04:43:21
【问题描述】:
我有一个输入条形码的文本框和一个搜索按钮。该按钮将显示一个单选按钮列表,其中包含与来自服务器的条形码相关的 3 块数据。
sheetDetail.aspx
<div>
<span>Enter Barcode: </span>
<asp:TextBox runat="server" ID="txtSearch" />
<asp:Button runat="server" ID="btnSearchBar" Style="background-color: #c9302c;" CssClass="btn btn-danger" Text="Search" OnClick="btnSearchBar_Click" />
<asp:RadioButtonList Font-Size="X-Small" RepeatLayout="Table" RepeatColumns = "2" ID="rediobtn" runat="server">
</asp:RadioButtonList>
</div>
sheetDetail.aspx.cs
protected void btnSearchBar_Click(object sender, EventArgs e)
{
eExistingSheetQuery existingSheetQuery = new eExistingSheetQuery();
string value = txtSearch.Text.Trim();
// Your Ado.Net code to get data from DB
rediobtn.Items.Clear();
DataTable dt = existingSheetQuery.GetSheetItem(value);
rediobtn.DataSource = existingSheetQuery.GetSheetItem(value);
rediobtn.DataBind();
}
eExistingSheetQuery.cs
public DataTable GetSheetItem(string barcode)
{
try
{
conn = new SqlConnection(estocktake);
conn.Open();
DataTable dtd = new DataTable();
GridView gvd = new GridView();
cmds = new SqlCommand(@"SELECT [invtid],[transtatuscode] ,[descr] FROM [Products] where ib_itemcode1='" + barcode + "' ;", conn);
adpt = new SqlDataAdapter();
adpt.SelectCommand = cmds;
cmds.ExecuteNonQuery();
adpt.Fill(dtd);
conn.Close();
conn.Dispose();
return dtd;
}
catch (Exception)
{
conn.Close();
conn.Dispose();
return null;
}
}
按钮将触发onclick,函数将开始运行,从文本框中获取值。
getsheetitem --> 运行查询并获取数据
将其绑定到gridview...
它显示的只是 System.Data.DataRowView。所有的收音机都是这样的..
我希望显示每个单选按钮。
[单选按钮] invtid - 描述 - 转换代码
任何帮助都会非常棒。
【问题讨论】:
标签: c# asp.net sql-server