ASP.NET Grabbing Individual Items for Stored Procedure
Here is my MasterPage Page_Load
DataTable sit开发者_JAVA技巧eParams = new DataTable();
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand("siteParametersGetAll", con))
{
using (SqlDataAdapter da = new SqlDataAdapter(cmd))
{
da.Fill(siteParams);
}
}
}
Now, I want to be able to grab certain rows without using 0,1,2,3:
Here is an example row: ID | siteParam | ParamValue 12 | domain | thisWebiste.com
Currently I would have to do something like this:
siteParams.Rows[0]["ID"].ToString();
But that can get confusing. Am I making sense?
Why not pass the primary key to your siteParametersGetAll and uniquely identify the row you want to get?
If you're wanting strongly typed stuff to work with, I recommend taking a look at Entity Framework. That would allow you to do something like this:
Response.Write(siteParameters.Id);
精彩评论