PDA

View Full Version : سوال: نمایش ندادن کنترل GridView



mehran63
دوشنبه 16 اردیبهشت 1392, 12:51 عصر
سلام
به مشکلی بر خوردم که یه خورده برام عجیبه
وقتی کنترل GridView رو روی صفحه قرار میدم در زمان اجرا کنترل رو نشون نمیده

سورس برنامه
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>

<asp:Button ID="Button1" runat="server" Text="Button" />

</div>
</form>
</body>
</html>

سورس در زمان اجرا

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>

</title></head>
<body>
<form method="post" action="Default.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMTk3NzU4NjY4D2QWAgIDD2QWAgIBDzwrABEAZBgBBQl HcmlkVmlldzEPZ2TgvEXuM0uG1ZYIhZtjSPYCYPgWyaJPFelre JRGKaAPnw==" />
</div>

<div class="aspNetHidden">

<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKC+LucCgKM54rGBvPs2AQF9K4k8YEjzwVJwT39LGvC2tl iLZvzo9/u83Pt" />
</div>
<div>
<div>

</div>

<input type="submit" name="Button1" value="Button" id="Button1" />

</div>
</form>
</body>
</html>


http://peron.tk/up/8b2926bd27d4.jpg

ahmad156
دوشنبه 16 اردیبهشت 1392, 12:54 عصر
دوست عزیز وقتی Data ای نداره چی نشون بده؟

DeveloperStudio
دوشنبه 16 اردیبهشت 1392, 13:26 عصر
به این صفحه سر بزن :

آموزش ارتباط GridView به پایگاه داده (http://developer1.ir/ASP_NET/GridView/Select_Data.aspx)

mehran63
دوشنبه 16 اردیبهشت 1392, 19:03 عصر
فرقی نداره
سورس پر کردن DataGrid
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
SqlDataAdapter myDataAdapter = new SqlDataAdapter();
DataSet myDataSet = new DataSet();
SqlCommand myCommand = new SqlCommand();

conn = new SqlConnection(@"Data source=.\SQLEXPRESS;AttachDbFileName=|DataDirector y|\DataBaseStore.mdf;Integrated Security=True; User Instance=True");

string str = "select * from Table_Store";
myDataAdapter.SelectCommand = new SqlCommand();
myDataAdapter.SelectCommand.Connection = conn;
myDataAdapter.SelectCommand.CommandText = str;
myDataAdapter.Fill(myDataSet);
GridView1.DataSource = myDataSet.Tables[0];
GridView1.DataBind();
}

ahmad156
دوشنبه 16 اردیبهشت 1392, 19:15 عصر
با BreakPoint چک کنین ببینین myDataSet.Tables[0] خالی نیست؟

mehran63
دوشنبه 16 اردیبهشت 1392, 19:54 عصر
درست شد
ولی منظورتون از این که با با BreakPoint چک کنین رو متوجه نشدم