AspxGridView를 사용하여 동적 데이터 바인딩을 수행하려고합니다. AutoGenerateColumn = true
을 설정하면 선택한 열의 열 이름이 표시되지만 레코드는 표시되지 않습니다. 자동 생성 열에 false를 설정하면 페이지 번호가 증가하지만 레코드가 표시되지 않습니다.동적 databind를 사용하여 AspxGridView에서 레코드를 표시하는 방법?
Asp.net 코드
<dx:ASPxGridView ID="ASPxGridView1" runat="server">
<SettingsPager PageSize="50">
</SettingsPager>
<Settings ShowFilterRow="True" ShowGroupPanel="True" />
<SettingsCommandButton>
<ShowAdaptiveDetailButton ButtonType="Image"></ShowAdaptiveDetailButton>
<HideAdaptiveDetailButton ButtonType="Image"></HideAdaptiveDetailButton>
</SettingsCommandButton>
<SettingsDataSecurity AllowDelete="False" AllowEdit="False" AllowInsert="False" />
<SettingsSearchPanel Visible="True" />
</dx:ASPxGridView>
CS 파일
protected void btnSearch_Click(object sender, EventArgs e)
{
string cs = ConfigurationManager.ConnectionStrings["HQMatajerConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = "select * from [HQMatajer].[dbo].[TransactionEntry] where itemid='74876'";
con.Open();
SqlDataReader rd = cmd.ExecuteReader();
//ASPxGridView1.Columns.Clear();
ASPxGridView1.AutoGenerateColumns = true;
ASPxGridView1.DataSource = rd;
ASPxGridView1.DataBind();
}
}
출력
를이 체크 아웃 – jignesh