i want to fix a grdview column width in page load event.
i bounded this gridview from c# and also uses a datasource from c#
i want to set width for “Address” column ,because it has long data.i also want to use auto scroll to this gridview .
here is my code…
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(str);
con.Open();
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand("Select DISTINCT FName+ ' ' +MName+ ' ' +LName as Name,"
+ " HomePhone,MobileNo1,"
+ " UPPER(ResAddr1) ++' '+ UPPER(Resaddr2) ++' '+ UPPER(ResAddr3) ++' '+ UPPER(Resaddr4) ++' '+ UPPER(Resaddr5) ++' '+ UPPER(Resaddr6) ++' '+ Pincode ++' '+City as Address,"
+ " g.Category,f.GroupName as 'Group',Seats,"
+ " dbo.CONCATWTOTSHOW(d.MemberId,d.GID,d.CID)As SeatNo,"
+ " AmountExpected,AmountReceived,Discount,AmountPending,b.Remarks as Reference, (d.MemberId)"
+ " from Person_Master a INNER JOIN Member_Master b ON a.PersonId=b.PersonId"
+ " LEFT JOIN Payment_Master c ON b.MemberId = c.MemberId"
+ " INNER JOIN SeatAssign_Master d ON b.MemberId = d.MemberId"
+ " INNER JOIN Year_Master e ON b.Year = e.Id"
+ " INNER JOIN Group_Master f ON d.Gid=f.Gid"
+ " INNER JOIN Category_Master g ON d.Cid=g.Cid "
+ " where b.Year=2 and g.Cid=2 and b.Active=1 and d.Active=1 ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
so do it in RowCreated event