Showing posts with label dynamically. Show all posts
Showing posts with label dynamically. Show all posts
0
Posted on 4:23 AM by prajeesh and filed under ,
Some situations it becomes necessary that the data that to be populated to a gridview or any other controls not directly come from a single function but we have to get it from some other source, like from multiple functions, a file system, or other sources. In such ssituations you can populate the DataSet or DataTable in your ASP.NET web page programmatically and then bind the web control with this data object.
Here i would like to explain a simple method to achieve this
DataTable dtHome = new DataTable();
dtHome.Columns.Add("Name",string.Empty.GetType());
dtHome.Columns.Add("City",string.Empty.GetType());
dtHome.Columns.Add("State",string.Empty.GetType());

Now we have successfully created a data table with empty rows with string data type fields, in next step we have to add rows in the data table.
dtHome.Rows.Add("Prajeesh","Calicut","Kerala");
Now we have added a single row to the data table, you can use this datatable to populate a grid view or other data presentation controls, it will display a single row of data.
GridView1.DataSource = dtHome;
GridView1.DataBind();

Shout it kick it on DotNetKicks.com
4
Posted on 9:34 AM by prajeesh and filed under , ,

In some websites we can see buttons like A A A to increse font size of your website for giving readability to disabled people also,we can do it many ways,one option is to dynamically change css or using javascript.here is a simple method using javascript to do this.


Step 1: Add the following Javascript in the insde the <HEAD> tag of your HTML.


<script language="JavaScript" type="text/javascript">


function changeFontSize(inc)


{


var p = document.getElementsByTagName('p');


for(n=0; n<p.length; n++) {


if(p[n].style.fontSize) {


var size = parseInt(p[n].style.fontSize.replace("px", ""));


} else {


var size = 12;


}


p[n].style.fontSize = size+inc + 'px';


}


}


</script>



Step 2: Insert the following HTML anywhere in your blog - you can customize the text or replace it with visual graphics (like the alphabet A - one small and the other one slightly large)

<a href="javascript:changeFontSize(1)">Increase Font Size</a>
<a href="javascript:changeFontSize(-1)">Decrease Font Size</a>

You can extend this to either all the HTML elements on your blog or limit it to only the text sections. The font size is specified in pixels.



Shout it kick it on DotNetKicks.com